浏览模式: 标准 | 列表 Tag: 指定字符串长度

Linux下shell取得字符串行数与指定字符串长度

有某个文本文件is36.txt,需要取得字符串行数指定字符串长度

linuxshell取得字符串行数:

  • cat is36.txt | wc -l

Linux下shell取得指定字符串长度(默认第一行):

  • cat is36.txt | wc -L

Linux下shell取得指定字符串长度(2p即第二行):

  • sed -n '2p' is36.txt | wc -L

Tags: linux, shell, 字符串行数, 指定字符串长度