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



## tad1214 (Jun 22, 2009)

```
[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?


----------



## DutchDaemon (Jun 22, 2009)

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]?


----------



## tad1214 (Jun 22, 2009)

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


----------



## lme@ (Jun 30, 2009)

Or use $NF in awk for the last column in a line. No need to count to 14.


----------



## DutchDaemon (Jun 30, 2009)

From an educational standpoint, there is


----------

