Re: calculate total logs size (121 Views)
Reply
Frequent Advisor
allanm77
Posts: 88
Registered: ‎06-27-2011
Message 1 of 4 (157 Views)
Accepted Solution

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?


thanks,

Allan.

Please use plain text.
Advisor
SoumitraC
Posts: 20
Registered: ‎03-21-2012
Message 2 of 4 (147 Views)

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
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,387
Registered: ‎03-06-2006
Message 3 of 4 (141 Views)

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.

Please use plain text.
Frequent Advisor
allanm77
Posts: 88
Registered: ‎06-27-2011
Message 4 of 4 (121 Views)

Re: calculate total logs size

Thanks SoumitraC, that worked!
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation