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.


In reply to A little golf anyone? by deprecated

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.