linux系統中統計每一行的字符數


 

1、awk命令

[root@PC3 test]# cat a.txt dfs dsafd d fgasdf safd ge [root@PC3 test]# awk -F "" '{print NF}' a.txt 3
5
1
6
4
2

 

2、

[root@PC3 test]# cat a.txt dfs dsafd d fgasdfd safd ge [root@PC3 test]# a=`awk 'END{print NR}' a.txt ` [root@PC3 test]# echo $a 6 [root@PC3 test]# for i in `seq $a`;do sed -n "$i"p a.txt | wc -c | awk '{print $0-1}';done 3
5
1
7
4
2

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM