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

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


Perhaps this would do:

find . -mtime -30 -exec ls -l {} \;| awk '{s+=$5} END {print "Total SIZE: " s}'


You could do this by having find output the size of each file, then total them up with awk

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


Try piping the output of your working find command to du to see if the output its satisfactory. You can use the du switches -c to produce a total, and optionally -h to make it human readable.

eg:

<your command> | du -c

becomes:

find . -name '*' -mtime -30 | du -c 

If you only want the total line:

find . -name '*' -mtime -30 | du -c | grep "total"

Produces output:

360     total

and using du -ch produces:

360K    total