Perl or cut or ??? to pull number from iostat

Code:
[root@abc ~]# iostat -d -x sda
Linux 2.6.9-55.0.9.ELsmp (abc.xxx.xxx)       06/22/2009

Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          0.04  28.55  1.57  6.26  155.46  279.11    77.73   139.55    55.52     0.12   15.92   5.42   4.24

Hey all, I am having trouble trying to get the %util into just that number from iostat. I am very limited on perl and cut seems to be struggling with it.

Can anyone help?
 
You mean something like
[cmd=]iostat -d -x sda | tail -1 | awk '{print $14}'[/cmd]
or [cmd=]iostat -d -x sda | awk '/^sda/ {print $14}'[/cmd]?
 
DutchDaemon said:
You mean something like
[cmd=]iostat -d -x sda | tail -1 | awk '{print $14}'[/cmd]
or [cmd=]iostat -d -x sda | awk '/^sda/ {print $14}'[/cmd]?

Second one is a winner!

Thanks!

-=Tom
 
Or use $NF in awk for the last column in a line. No need to count to 14. ;)
 
Back
Top