Total number of lines in a directory

后端 未结 7 2065
礼貌的吻别
礼貌的吻别 2021-01-13 08:52

I have a directory with thousands of files (100K for now). When I use wc -l ./*, I\'ll get:

 c1            ./test1.txt
 c2            ./tes         


        
7条回答
  •  旧时难觅i
    2021-01-13 09:29

    Below command will provide the total count of lines from all files in path

    for i in    `ls- ltr | awk ‘$1~”^-rw”{print $9}’`; do wc -l $I | awk ‘{print $1}’; done >>/var/tmp/filelinescount.txt  
    Cat /var/tmp/filelinescount.txt| sed -r “s/\s+//g”|tr “\n” “+”| sed “s:+$::g”| sed ’s/^/“/g’| sed ’s/$/“/g’ | awk ‘{print “echo” “ “ $0”+bc”}’| sh
    

提交回复
热议问题