Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
hi all, for an example : df -k output shows: $ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/cciss/c0d0p6 3099260 1117760 1824068 8% / /dev/cciss/c0d0p1 256666 18065 225349 ...
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    9

    Exclamation sed scripting help needed

    hi all,

    for an example :
    df -k output shows:

    $ df -k
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/cciss/c0d0p6 3099260 1117760 1824068 8% /
    /dev/cciss/c0d0p1 256666 18065 225349 8% /boot
    none 8219180 0 8219180 0% /dev/shm
    /dev/mapper/vglocal-home
    1032088 245172 734488 26% /export/home
    /dev/mapper/vglocal-fisc
    4128448 308516 3610220 8% /fisc
    /dev/mapper/vglocal-backup
    2064208 252008 1707344 13% /fisc/backup
    /dev/mapper/vglocal-perf
    4128448 1046068 2872668 27% /fisc/perf
    /dev/mapper/vglocal-opt
    2064208 2062405 1803 80% /opt
    /dev/cciss/c0d0p7 2063504 456700 1501984 24% /var
    /dev/mapper/vglocal-crash
    17546044 77808 16576948 1% /var/crash
    /dev/cciss/c0d0p2 17544368 77800 16575364 1% /var/diskdump
    tmpfs 524288 523765 523 94% /tmp

    I want to search for above 80% usage...
    for the above example /tmp and /opt Filesystem are exceeding

    i need to add a word "HI" before starting of the line and "BYE" after the line
    in our case:
    HI tmpfs 524288 523765 523 94% /tmp BYE

    I'm new to sed scripting, anybody help is greatly appreciated.

  2. #2
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Code:
    df -k | awk 'NR>1 && ($5+0)>80{print "HI "$0 "bye"}'

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    9

    Thumbs down

    hi

    i tried u r choice:
    df -k | awk 'NR>1 && ($5+0)>30{print "HI "$0 "bye"}'
    HI /dev/cciss/c0d0p6 3099260 1082660 1859168 37% /bye
    HI tmpfs 524288 407204 117084 78% /tmpbye

    the problem is here only two F/S are selecting, whereas for above 30% there are morethan 10 F/S, but it is not showing...

    any other luck ?

  4. #4
    Banned
    Join Date
    Jun 2009
    Posts
    68
    Code:
    df -k | sed -n -e 's/\(.*80%.*\)/HI & BYE/p'
    For 80% specifically.
    Don't know if that helps ...

  5. #5
    Banned
    Join Date
    Jun 2009
    Posts
    68
    Code:
    df -k | sed -n -e 's/\(.*[80-100]%.*\)/HI & BYE/p'

  6. #6
    Just Joined!
    Join Date
    Jan 2007
    Posts
    9
    i tried this code
    df -k | sed -n -e 's/\(.*[80-100]%.*\)/HI & BYE/p'


    here it is showing only the values which are containing "8" "0" "10" "11" and "1"

    but the problem here is
    I need select all F/S which is above 80%...

  7. #7
    Banned
    Join Date
    Jun 2009
    Posts
    68
    When I posted my response I had practically just gotten done reading IBM's three-part sed tutorial. I tried it on my machine and it worked, but I only had low percentages. I haven't read more on it since ...

  8. #8
    Banned
    Join Date
    Jun 2009
    Posts
    68
    I don't know how to do it, I wasn't thinking at all about [ ... ] being a character class. It should be 0-9 a-z etc.

  9. #9
    Banned
    Join Date
    Jun 2009
    Posts
    68
    I'm slapping myself.
    I'm sorry. This has happened twice to me already, that I posted something that was wrong.
    Here:
    Code:
    df -k | sed -n -e 's/\(.*[8-90][0-9]%.*\)/HI & BYE/p'
    That's for 80-99%.
    I can't help more right now, I'd have to read more about sed.
    It only looks like I'm trying to get my post count up.

  10. #10
    Just Joined!
    Join Date
    Jan 2007
    Posts
    9

    Thumbs up

    Hi nopycckn,

    I tried your code

    df -k | sed -n -e 's/\(.*[8-90][0-9]%.*\)/HI & BYE/p'

    It works fine and which I expected.

    Thanks a lot !

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...