Fast Linux file count for a large number of files

后端 未结 17 2645
名媛妹妹
名媛妹妹 2020-12-22 17:21

I\'m trying to figure out the best way to find the number of files in a particular directory when there are a very large number of files (more than 100,000).

When the

17条回答
  •  猫巷女王i
    2020-12-22 17:45

    I realized that not using in memory processing, when you have a huge amount of data, is faster than "piping" the commands. So I saved the result to a file and analyzed it afterwards:

    ls -1 /path/to/dir > count.txt && cat count.txt | wc -l
    

提交回复
热议问题