You can use:
awk '/%idle/ } /^Average:/ '
This stores the column where %idle
is and substracts one because Average:
does not have the PM/AM column. Then, it prints that column when the line starts with Average:
.
Test
With sample1:
$ awk '/%idle/ } /^Average:/ ' a 99.50
With sample2:
$ awk '/%idle/ } /^Average:/ ' b 99.94