Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command is
echo date
`top -b -n1 | grep -e Cpu -e Mem`
I get the output in 3 separate lines.
Tue Feb 24 15:00:03
Cpu(s): 3.4% us, 8.5% sy .. ..
Mem: 1011480k total, 226928k used, ...
. My desired output is
Tue Feb 24 15:00:03 3.4% 8.5% ... 1011480k 226928k
I have tried to use awk to process the output from the grep
tob -b -n1 | grep -e Cpu -e Mem | awk '{print $2 $4
and I only the figures I required, but the output still spans 3 lines
2.8% 7.0%
1011480k 227896k
How should I modify the awk command to get everything on one line with the date at the front ?