shell统计每一行字符数的三种方法 $cat test.txt SlNAC2 ,SlNAC2_2 ,SlNAC2_2 ##### 方法一: $awk -F "" '{print NF}' test.txt 6 9 9 ##### 方法二: $cat test.txt|while read i;do echo $i|wc -c|awk '{print $2-1}';done 6 9 9 ##### 方法三: $awk '{print length($0)}' test.txt 6 9 9