View Full Version : Using sed/awk to display CPU/MEM% with top

July 27th, 2008, 01:02 AM
I want to use sed/awk to parse the output of top to display just the total CPU and memory %, but I have no clue how to use sed/awk and the man pages weren't very useful... any bash gurus out there?

July 27th, 2008, 02:59 AM
you can look at the top info or man page on options that can allow you to select which fields you want to view. Also to get just the total CPU/mem (the top first few lines)

top -n 1 | awk 'BEGIN{FS="[:,]"}NR==3||NR==4{print $2}'