I require some help with a homework question. I have the following data in a file that I need to parse:
Output-------------------------- Input---------------- Random----
-Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU
50.0 36112 34.1 138026 1.9 179048 7.0 51361 51.1 312242 4.3 15211.4 10.3
What I need is a way to extract the data from the Block column for both the output and input columns. For example:
Output Block:
K/sec: 138026
%CPU: 1.9
Input Block:
K/sec: 312242
%CPU: 4.3
I am limited to using sed, awk, cut, and grep.
parse_data.txt:- Is the file where the data is present.
more parse_data.txt | grep -v “-” | sed ‘s/\ /\ /g’ | awk ‘{print $4 ” “$5 ” ” $10 ” ” $11}’
CPU and k/sec data with respect Output and Input block
is been retrieved, as shown below,
Output got is:
Hope this solves your problem!!!!!