Hi Bakunin (looks funny with a cap :)),
Although I am getting close to 20 years professionally with AIX (and nearly 10+ more while it was not my favorite) - I have never had access to the labs.
Back in 1978 - is when I started with UNIX v6 and v7 on PDP, and "college access to the kernel". The deep stuff I learned back then.
As to things like the meaning of -h
- like anyone (or perhaps I am alone) not starting in GNU/Linux, I fell over it. From AIX I was used to df -g
, and when coreutils are first in my PATH that does not work. I requested it (support for -g) as a feature - and got turned down "because we have -h". That was the day I learned about "-h" and how it relates to du
and ds
. Looking at Maddy's question - it seems he is looking for a specific layout - with the letters K, M or G behind the number, rather than as a counter.
Maddy,
Working the way it has been in UNIX for years and years (du -sk goes back to 1978 and earlier perhaps) - is not going to work for you.
If I understand you correctly - what you are asking is not standard in UNIX aka POSIX systems. It is not even standard in Linux, because it is GNU
- not Linux
- who makes these choices. And GNU stands for GNU Not Unix
- which they take seriously. If they feel they have a better idea, then they do it that way. They are "not UNIX/POSIX" and are free to make any change they wish. Fortunately, they also try to be compatible with POSIX behavior most of the time.
POSIX does not have -h - so GNU can define that anyway they wish. And so the following outputs show - if you need/want file system stats as you describe - either you will need to write an awk script (or something compareable) to convert the first number that AIX/POSIX du behavior is providing - OR - install coreutils.
Happy hunting!
Both AIX and COREUTILS versions give the same output for the arguments -k, (-sk to sum directories), -m or -sm.
Note the full path of the command:
AIX
michael@x071:[/home/michael]/usr/bin/du -sk /tmp/* | sort -n | tail
3520 /tmp/openssh_xxx
4704 /tmp/waitUploaderTmp_7078008.0
4704 /tmp/waitUploaderTmp_7078008.0.tmp
8452 /tmp/ibm.bff
17656 /tmp/891c0bbd
27888 /tmp/93b06705msd
40008 /tmp/aixtools.perl.5.14.4.0.I
41152 /tmp/named.tcpdump
56900 /tmp/rootvg.20140814.bff.bz2
60332 /tmp/forums.bff.bz2
COREUTILS
michael@x071:[/home/michael]/opt/bin/du -sk /tmp/* | sort -n | tail
3520 /tmp/openssh_xxx
4704 /tmp/waitUploaderTmp_7078008.0
4704 /tmp/waitUploaderTmp_7078008.0.tmp
8452 /tmp/ibm.bff
17656 /tmp/891c0bbd
27888 /tmp/93b06705msd
40008 /tmp/aixtools.perl.5.14.4.0.I
41152 /tmp/named.tcpdump
56900 /tmp/rootvg.20140814.bff.bz2
60332 /tmp/forums.bff.bz2
COREUTILS using -h
I think this is what you seem to be looking for - with the letters behind the size. However, note the very very different results when using sort!
michael@x071:[/home/michael]/opt/bin/du -sh /tmp/* | sort -n | tail
440K /tmp/jpzcd8-alqe
440K /tmp/jpzcdV-alqg
440K /tmp/jpzcdYDalyc
500K /tmp/jpzcd-4al7d
500K /tmp/jpzcd6-alqf
500K /tmp/jpzcdKDalyb
500K /tmp/jpzcd_4al7c
500K /tmp/jpzcd_6al7a
Now my largest file is not showing up at the end - because numerically " sort
" 500K is larger than 59M. So, just be careful when using sort!
michael@x071:[/home/michael]/opt/bin/du -h /tmp/forums.bff.bz2
59M /tmp/forums.bff.bz2