1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.


Discussion in 'The Hummy Arms' started by Fmrl, Apr 17, 2012.

  1. Fmrl

    Fmrl Member

    Little bit rusty on sed but I think this will do the trick...

    display "Disk: `df -k | grep /dev/sda2 | sed 's/\(.*\) \(.*\) \(.*\)/\2/'`"
  2. xyz321

    xyz321 Well-Known Member

    I was going to suggest something like this in order to overcome the 5% error due to the ext3fs reserved blocks.
    display `df /dev/sda2 |awk '(/^\/dev/){printf ("%d%%\n",$3/$2 * 100)}'`
  3. af123

    af123 Administrator Staff Member

    humax# df -h /dev/sda2 | sed '1d;s/  */ /g' | cut -d\  -f5
  4. Fmrl

    Fmrl Member

    cut is cheating :)

    or I'd have suggested...

    df -h /dev/sda2 | grep /dev/sda2 | cut -c 52-55
  5. af123

    af123 Administrator Staff Member

    True, but I used sed to replace tr : )

    humax# df -h /dev/sda2 | sed '1d;s/.* \([0-9]*%\).*/\1/'
  6. Fmrl

    Fmrl Member

    Ahh, regexp on the %, I never thought of that - I've been out-geeked :oops:
  7. Frosty

    Frosty Member

    I feel like I've woken up and everyone's talking an alien language :) I really need to learn linux!
  8. Black Hole

    Black Hole Theloniuos Abbot

    Careful, af will take exception and tell you it's bash or something, not Linux!
    af123 likes this.
  9. af123

    af123 Administrator Staff Member

    Well, in this case mostly sed : )
  10. jack616

    jack616 Member

    I think you should all just sh....
  11. af123

    af123 Administrator Staff Member

    Happy to continue the conversation, but probably not here!

    @Mods - would you mind splitting this thread from post 75 to the Hummy Arms please?
  12. af123

    af123 Administrator Staff Member

    Don't learn bash, learn Bourne shell (sh). You can always learn the Bash extensions later.

    I'm tired of people coming for interview for jobs involving shell programming (we don't use bash) and not realising the difference!
    They're the same people who almost invariably tell us that our "Up arrow is broken"* and the "Cursor keys aren't working in vi" (and also tend to pronounce vi as in vie instead of Vee Eye).

    * - we aren't allowed to use any shell with a history due to security policy constraints.
  13. af123

    af123 Administrator Staff Member

    Right - we can rant away to our heart's content now... or is that just me?
    (Thanks for moving the posts Brian)
  14. 4291

    4291 Well-Known Member

  15. Fmrl

    Fmrl Member

    Fortunately I'm the chap who enforces security policies so I don't have to worry about conforming to them. :p