when I do the follwing , then we get output
iostat -x 1|grep sdb
sdb 0.00 13.65 4.17 11.65 113.72 991.55 139.74 0.24 15.39 3.27 19.73 0.46 0.72
sdb 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
now I want to cut the second field , but now we not get output
[root@linux1 ~]# iostat -x 1|grep sdb | awk '{print $2}'
also that , no output from pipe ,
iostat -x 1|grep sdb | more
why?
Could you please try following.
iostat -x 1 | grep --line-buffered "sdb" | awk '{print $2}'
OR with only awk
:
iostat -x 1 | awk '/sdb/{print $2;fflush();}'
OR
iostat -x 1 | awk '$1=="sdb"{print $2;fflush();}'
From man awk
page:
fflush([file]) Flush any buffers associated with the open output file or pipe file. If file is missing or if it is the null string, then flush all open output files and pipes.