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

前端 未结 7 1004
长发绾君心
长发绾君心 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:35

    One alternate solution is to use bash for loop:

    for i in `find . -name '*.txt'`; do du -hc $i | grep -v 'total'; done
    

    This is good for when you need more control of what happens in the loop.

提交回复
热议问题