Why does “find . -name *.txt | xargs du -hc” give multiple totals?

前端 未结 7 1001
长发绾君心
长发绾君心 2020-12-30 10:12

I have a large set of directories for which I\'m trying to calculate the sum total size of several hundred .txt files. I tried this, which mostly works:

fin         


        
相关标签:
7条回答
  • 2020-12-30 10:54
    find . -print0 -iname '*.txt' | du --files0-from=-
    

    and if you want to have several different extensions to search for it's best to do:

    find . -type f -print0 | grep -azZEi '\.(te?xt|rtf|docx?|wps)$' | du --files0-from=-
    
    0 讨论(0)
提交回复
热议问题