Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (None)
    As of 2024-04-25 03:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found