1834149 Members
2274 Online
110064 Solutions
New Discussion

Re: Disk Space Used

 
SOLVED
Go to solution
intp
Frequent Advisor

Disk Space Used

Hi,

this is my home directory... /export/home/emp1001

like wise many employees will have their own
home dirs. how to get following report. it needs to consolidate at the home dir level.

/export/home/emp1001 201MB
/export/home/emp1002 25MB
/export/home/emp1003 600MB
/export/home/emp1004 100KB

Also if i want to see only those used more than 250MB space.

should return
/export/home/emp1003 600MB


Thanks.

10 REPLIES 10
James R. Ferguson
Acclaimed Contributor

Re: Disk Space Used

Hi:

# du -xk /export/home | sort -k2

...summarizes in 1k blocks

Regards!

...JRF...
intp
Frequent Advisor

Re: Disk Space Used

Tried...

/export/home>du -xk /export/home | sort -k2
du: illegal option -- x
usage: du [-a][-d][-k][-r][-o|-s][-L] [file ...]
intp
Frequent Advisor

Re: Disk Space Used

man du


The following options are supported for /usr/xpg4/bin/du
only:

-r By default, generate messages about directories that
cannot be read, files that cannot be opened, and so
forth.

-x When evaluating file sizes, evaluate only those files
that have the same device as the file specified by the
file operand.
James R. Ferguson
Acclaimed Contributor

Re: Disk Space Used

Hi (again):

What release are you running?

In any event:

# du -ks /export/home/*

...is closer to what you first asked about.

Regards!

...JRF...
intp
Frequent Advisor

Re: Disk Space Used

Thanks
Can i get the result in Mega Bytes ?
James R. Ferguson
Acclaimed Contributor

Re: Disk Space Used

Hi (again):

# du -ks /export/home/* | awk '{printf "%8.2f %s\n",$1/1024,$2}'

Regards!

...JRF...
Hein van den Heuvel
Honored Contributor
Solution

Re: Disk Space Used

Untested...

# du -ks /export/home/* | awk '{mb=$1/1024; total += mb; if (mb>250) {printf "%8.2f %s\n",mb,$2}} END {'printf "%8.2f total",total}'

Cheers,
Hein.



intp
Frequent Advisor

Re: Disk Space Used

Not working ... meaning no errors / no results ...just hanging.. need to ctrl+c to exit...

Quote:
--------
Untested...

# du -ks /export/home/* | awk '{mb=$1/1024; total += mb; if (mb>250) {printf "%8.2f %s\n",mb,$2}} END {'printf "%8.2f total",total}'

Cheers,
Hein.
Hein van den Heuvel
Honored Contributor

Re: Disk Space Used

There's a minor quote problem.
The accidental single quote after END { causes the awk program to terminate and the intended terminator quote makes the shell read some more.

Try:

# du -ks /export/home/* | awk '{mb=$1/1024; total += mb; if (mb>250) {printf "%8.2f %s\n",mb,$2}} END {printf "%8.2f total",total}'

Hein.



Peter Nikitka
Honored Contributor

Re: Disk Space Used

Hi,

1) I bet you are on a SUN
2) perhaps there are no homes around exceeding your limit -> set it at 25MB for testing
3) you may come into NFS territory - perhaps you have to check this and exclude them (better run your checker locally).

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"