Total number of lines in a directory

后端 未结 7 2021
礼貌的吻别
礼貌的吻别 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条回答
  •  说谎
    说谎 (楼主)
    2021-01-13 09:22

    This will give you the total count for all the files (including hidden files) in your current directory :

    $ find . -maxdepth 1 -type f  | xargs wc -l  | grep total
     1052 total
    

    To count for files excluding hidden files use :

    find . -maxdepth 1 -type f  -not -path "*/\.*"  | xargs wc -l  | grep total
    

提交回复
热议问题