fileunixcommandsize

Unix command line : How to get the total size of modified files in the last 30 days


I want to know how to get the total size of the modified files in the last 30 days.

I have found this command who onlye give me the list of the modified files in the last 30 days.

find . -name '*' -mtime -30

It is useful but I want to know the TOTAL size of this list.

Can someone help getting through this please?


Solution

  • Perhaps this would do:

    find . -mtime -30 -printf '%s\n' | awk '{s+=$1} END {print "Total SIZE: " s}'
    

    This will render Total SIZE: 11726681

    I would like to highlight the formatting addition by balder mentioned in a comment:

    find . -mtime -30 -printf '%s\n' | awk '{s+=$1} END {print  s}' | numfmt --to=iec
    

    This will output: 12M