sed or awk 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

Try...

awk '{s=substr($5,1,match($5,"%")-1)
if (s > 80)
   $0="Hi "$0" Bye"
   print
   }' inputfile

Hi All

I want to show df -h, whichever F/S is 80% above i need to add "HI" at Starting of the Line and "BYE" at the ending of the line.

Example shown as below:

[itgcead7@lrtp68 cgi-bin]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p6 3.0G 1.1G 1.8G 37% /
/dev/cciss/c0d0p1 251M 18M 221M 8% /boot
none 7.9G 0 7.9G 0% /dev/shm
/dev/mapper/vglocal-home
1008M 725M 233M 76% /export/home
/dev/mapper/vglocal-fisc
4.0G 2.0G 1.9G 52% /fisc
/dev/mapper/vglocal-backup
2.0G 266M 1.7G 14% /fisc/backup
/dev/mapper/vglocal-perf
4.0G 806M 3.0G 22% /fisc/perf
/dev/mapper/vglocal-opt
2.0G 153M 1.8G 8% /opt
/dev/cciss/c0d0p7 2.0G 297M 1.6G 16% /var
/dev/mapper/vglocal-crash
17G 76M 16G 1% /var/crash
/dev/cciss/c0d0p2 17G 76M 16G 1% /var/diskdump
HI tmpfs 512M 412M 101M 81% /tmp BYE

Try this,

df -k | awk '$5 >= "70%" { printf "HI "; printf; printf " BYE"; printf "\n"; }'

I don't think you can compare it with %...

I have checked in my server and its works fine!!

Hi,

Try this.

894t005 $df -h |awk '$5>80{print "HI " $0 " BYE"}'|grep -v "Filesystem"HI /lib 9.8G 8.6G 1.1G 89% /lib BYE
HI /platform 9.8G 8.6G 1.1G 89% /platform BYE
HI /sbin 9.8G 8.6G 1.1G 89% /sbin BYE
HI /usr 9.8G 8.6G 1.1G 89% /usr BYE
HI /platform/SUNW,Sun-Fire-T200/lib/libc_psr/libc_psr_hwcap1.so.1 9.8G 8.6G 1.1G 89% /platform/sun4v/lib/libc_psr.so.1 BYE
HI /platform/SUNW,Sun-Fire-T200/lib/sparcv9/libc_psr/libc_psr_hwcap1.so.1 9.8G 8.6G 1.1G 89% /platform/sun4v/lib/sparcv9/libc_psr.so.1 BYE

df -k | nawk '{tmp=$5;sub(/%/,"",tmp);if(tmp>=80){print $0}}'