Hello Experts,
I was trying to awk out some data out of a text file.
Below is a sample file which I have
xxx ***Wed Jun 28 18:00:59 CDT 2015
avg-cpu: %user %nice %system %iowait %steal %idle
17.10 0.00 4.56 2.86 0.00 75.48
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdd 0.00 0.00 1.00 1.00 0.50 0.50 1.00 0.00 1.00 1.00 0.20
sdf 0.00 0.00 28.00 910.00 865.00 9985.00 23.13 1.38 1.47 0.12 11.70
sde 0.00 0.00 0.00 2.00 0.00 4.00 4.00 0.00 1.00 1.00 0.20
xxx ***Wed Jun 28 18:01:59 CDT 2015
avg-cpu: %user %nice %system %iowait %steal %idle
17.10 0.00 4.56 2.86 0.00 75.48
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdd 0.00 0.00 1.00 1.00 0.50 0.50 1.00 0.00 1.00 1.00 0.20
sdf 0.00 0.00 28.00 910.00 865.00 9985.00 23.13 1.38 1.47 0.12 12.70
sde 0.00 0.00 0.00 2.00 0.00 4.00 4.00 0.00 1.00 1.00 0.20
I want an output like below
xxx ***Wed Jun 28 18:00:59 CDT 2015
avg-cpu: %user %nice %system %iowait %steal %idle
17.10 0.00 4.56 2.86 0.00 75.48
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sdf 0.00 0.00 28.00 910.00 865.00 9985.00 23.13 1.38 1.47 0.12 11.70
xxx ***Wed Jun 28 18:01:59 CDT 2015
avg-cpu: %user %nice %system %iowait %steal %idle
17.10 0.00 4.56 2.86 0.00 75.48
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sdf 0.00 0.00 28.00 910.00 865.00 9985.00 23.13 1.38 1.47 0.12 12.70
Basically, the awk is searching value on columns 1-12 >10 and print the whole line & the header lines.
I managed to get the command to grep the values on columns. But couldn't find a way to just print the 4 lines above the one which start with Device:
awk -F "[: ]" '{for (i=12;i<=NF;i++) if ($i>=50){print $0;next}}' infile
Thanks in advance
Dev