Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Languages and Scripting
Showing results for 
Search instead for 
Did you mean: 

calculate total logs size

Go to solution
Frequent Advisor

calculate total logs size

Hi All,


I am on a n/w filer and trying to calculate the size of all log file from the past 24hrs.


find . -mtime -1 -type f |xargs du -sxh (this gives me the size of individual files)


How do a calculate with xargs so I get a total summation of files in MB or GB?



Frequent Advisor

Re: calculate total logs size

Use awk to add up the values?


<your commands> | awk 'BEGIN {sum=0} {sum=sum+$1} END {printf("%.2f\n", sum/1024)}'


You can modify the calculation above to suite your needs accordingly (e.g. not divide by 1024 if the value is less than 1024).


Soumitra C
HP-UX Compilers
Dennis Handly
Acclaimed Contributor

Re: calculate total logs size

You should probably replace xargs by: -exec ll -og {} +

Then just add up column $3 and divide by MB or GB.

Frequent Advisor

Re: calculate total logs size

Thanks SoumitraC, that worked!