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 ...
- 06-25-2009 #1Just Joined!
- Join Date
- Jan 2007
- Posts
- 9
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.
- 06-27-2009 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
Code:df -k | awk 'NR>1 && ($5+0)>80{print "HI "$0 "bye"}'
- 06-28-2009 #3Just Joined!
- Join Date
- Jan 2007
- Posts
- 9
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 ?
- 06-28-2009 #4Banned
- Join Date
- Jun 2009
- Posts
- 68
For 80% specifically.Code:df -k | sed -n -e 's/\(.*80%.*\)/HI & BYE/p'
Don't know if that helps ...
- 06-28-2009 #5Banned
- Join Date
- Jun 2009
- Posts
- 68
Code:df -k | sed -n -e 's/\(.*[80-100]%.*\)/HI & BYE/p'
- 06-30-2009 #6Just 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%...
- 07-02-2009 #7Banned
- 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 ...
- 07-02-2009 #8Banned
- 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.
- 07-02-2009 #9Banned
- 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:
That's for 80-99%.Code:df -k | sed -n -e 's/\(.*[8-90][0-9]%.*\)/HI & BYE/p'
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.
- 07-07-2009 #10Just Joined!
- Join Date
- Jan 2007
- Posts
- 9
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 !


Reply With Quote