Operating System - HP-UX
1834650 Members
1800 Online
110069 Solutions
New Discussion

Re: Something similar to "du -sh'

 
amit mehta_2
Regular Advisor

Something similar to "du -sh'

Hi,

On a linux machine:
$ du -sh ./
405M ./

Above gives disk usage in human readable format in Linux.
Do we have anything similar in HP-UX ?
8 REPLIES 8
Robert-Jan Goossens
Honored Contributor

Re: Something similar to "du -sh'

Hi,

# du -ks
Calculates the block count in 1024-byte (kilobytes) units rather than the default 512-byte units.

Regards,
Robert-Jan
Pete Randall
Outstanding Contributor

Re: Something similar to "du -sh'

Or use bdf.


Pete

Pete
Ralph Grothe
Honored Contributor

Re: Something similar to "du -sh'

I am afraid,
HP-UX isn't "human readable",
at least in this respect.
You would have to increase readbility by yourself, like e.g.

$ du -skx /opt|awk '{print$1/2^10}'
3094.95
Madness, thy name is system administration
Bill Hassell
Honored Contributor

Re: Something similar to "du -sh'

Or you can use the attached script. It will summarize each directory in Gb, Mb, Kb, etc. Adjust the code as needed.


Bill Hassell, sysadmin
amit mehta_2
Regular Advisor

Re: Something similar to "du -sh'

Hi Ralph,

i tried it on my linux machine.

$ du -sh ./
405M ./ <--------
$ du -skx ./|awk '{print$1/2 ^10}'
404.32 <---------

~amit
Frank de Vries
Respected Contributor

Re: Something similar to "du -sh'

also works is:

find -type f | du -sk
or
find -type f -prune | du -sk



Look before you leap
Ralph Grothe
Honored Contributor

Re: Something similar to "du -sh'

amit,

probably some rounding or kibi vs. kilo issue?

I went on one of our RHFC3 linux boxes.
Oops, have you seen this?

# du -sH /usr
du: WARNING: use --si, not -H; the meaning of the -H option will soon
change to be the same as that of --dereference-args (-D)
824M /usr


If I look up the Warning about deprecated -H switch in the manpage of *my* version of du,
this indeed seems to relate to the notoriuos kibi vs. kilo issue.

excerpt from man du:

-H like --si, but also evokes a warning; will soon change to be
equivalent to --dereference-args (-D)

--si like -h, but use powers of 1000 not 1024


Well, I guess for "humans" it is considered too confusing to calculate in powers of base 2 rather than 10.
On the other hand I suspect this has been inculcated by HW vendors who can better bost with higher capacity figures of their storage devices.



Madness, thy name is system administration
Peter Nikitka
Honored Contributor

Re: Something similar to "du -sh'

Hi,

a little modification of Ralf's commandline to get a more linux-like output:

du -skx /opt|awk '{printf("%dM %s\n",$1/2^10,$2)}'

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"