Hi
I will appreciate it if you can help me out. I have a file that contains this data
System Load: 3244 card: 1903 CPU: 6% card: 1904 CPU: 6% card: 1905 CPU: 28% card: 1906 CPU: 28% card: 1907 CPU: 36% card: 1908 CPU: 37%
I need to manipulate and output this as
system_load:3244 card1903:6 card1904:6 card1905:28 card1906:28 card1907:36 card1908:37
I have tried to use this awk script i have below
data=`cat data_file`
system_load=`echo $data | awk '{print $6}'`
card1903_p=`echo $data | awk '{print $10}'`
card1903=`echo $card1903_p | nawk -F "%" '{print $1}'`
card1904_p=`echo $data | awk '{print $14}'`
card1904=`echo $card1904_p | nawk -F "%" '{print $1}'`
......
echo "system_load:$system_load card1903:$card1903 card1904:$card1904 ..."
The problem i have is, this just uses the position of the value but i need the script to be able to match the string as in card: 1903 and pick the CPU value 6.
So in case the positions of the string changes the values will not be mismatched.
I will greatly appreciate your help in doing this
Thanks