[ILUG] Script for Calculating Disk Usage
Francis Daly
francisdaly at gmail.com
Tue Jan 19 21:51:02 GMT 2010
2010/1/19 Paulo Jacob <paulo.jacob at gmail.com>:
> On 01/19/2010 07:29 PM, FRLinux wrote:
>> On Tue, Jan 19, 2010 at 7:05 PM, Walter Faleiro<curtorkar at gmail.com>
>> wrote:
Hi there,
>>> I have a command for calculating disk usage in a folder per usage basis
To answer the later questions: that's the bit you're missing -- disk
usage *per user*.
>>> find ./ -printf "%u %k/\n"| awk '{user[$1]+=$2}; END{ for( i in user)
>>> print i " " user[i]}'
It does the sums based on the file owner and 1 kB disk blocks.
>>> If I use %s it shows the usage as 2.7 e+09 etc hence am using %k.
>>>
>>> I get the output as
>>> <user> <usage in kb>
>>>
>>> what math can I apply to convert the usage to GB?
Divide by a million.
Or by 1024*1024, depending on how accurate you want to be.
Replace the final
user[i]
with
user[i]/1048576
(or, as Nexor said, 2^20)
Output will be printed according to CONVFMT, which defaults to "%.6g"
-- set that (for example, in the END block) to decide what rounding
and decimal places you want to see.
>> What's wrong with du -sh ? Or am i just completely missing the point here?
> I don't understand it either Steph. We both must be missing the point here.
It looks like a kind of advisory quota system, on shared writable space.
f
More information about the ILUG
mailing list