http://www.perlmonks.org?node_id=209212

I am finding myself irritated by solaris 8's lack of du and df -h. Especially now that solaris 9 actually has the flag. So I am preparing to write a small shell one-liner or perl if I cant do it with awk or sed (the principle being, if youre going to do it a bunch of times, you want it to be fast).

So the challenge is:

Replicate the output of a du or df with the -h flag. Example:

minotaur% df -k | grep c0t1 /dev/dsk/c0t1d0s1 1269615 814811 391324 68% /usr /dev/dsk/c0t1d0s3 245407 44583 176284 21% /var /dev/dsk/c0t1d0s0 424519 187200 194868 49% /home minotaur% df -h | grep c0t1 /dev/dsk/c0t1d0s1 1.2G 796M 382M 68% /usr /dev/dsk/c0t1d0s3 240M 44M 172M 21% /var /dev/dsk/c0t1d0s0 415M 183M 190M 49% /home
Replicate it in such a way that it can be passed input from standard in.

Special note: if you can do it in sed or some other shell command (ideally a common one, let's not be linux or solaris or bsd centric here), that is fine, given the intent is to have a working shell alias. Contestants will be judged from the first character after the pipe:

alias du 'du | perl ... '

So, yeah, that means you get a 1 character bonus for using sed, but I doubt your command would be as compact.

Consider it a Unix "brown bag" golf. Enjoy!

brother deprecated

--
Laziness, Impatience, Hubris, and Generosity.