I am using the terminal in MAC OS. I want to get on only the total ideal CPU from the top command (just ideal cpu) and stor it to a file.
I have tried this:
top | grep -w "CPU usage: "
And i got this :
/Test/temp1 » top | grep "CPU usage: " 130 ↵
CPU usage: 5.45% user, 11.77% sys, 82.77% idle
CPU usage: 3.20% user, 3.51% sys, 93.27% idle
CPU usage: 2.64% user, 2.76% sys, 94.59% idle
CPU usage: 3.18% user, 2.61% sys, 94.19% idle
.
I want to store only the last metrics en every line which is "82.77% idle" but without the "% and idel" word, only I want the amount of ideal CPU to store it in a file. Ex:
82.77
93.27
94.59
94.19
I appreciate your help ,,,
sed 's/.*\s\([0-9.]*\)%.*/\1/'