Total number of lines in a directory

后端 未结 7 2088
礼貌的吻别
礼貌的吻别 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:29

    Credit: this builds on @lifecrisis's answer, and extends it to handle large numbers of files:

    find . -maxdepth 1 -type f -exec cat {} + | wc -l
    

    find will find all of the files in the current directory, break them into groups as large as can be passed as arguments, and run cat on the groups.

提交回复
热议问题