I use a specific ps command namely
ps -p <pid> -o %cpu, %mem
which gives me a result like
%CPU %MEM
15.1 10.0
All i want to do is to just print these numbers like 15.1 and 10.0 without the headers. I tried to use the 'cut' . But it seems to work on every line.
i.e
echo "$(ps -p 747 -o %cpu,%mem)" | cut -c 1-5
gives something like
%CPU
8.0
How to get just the numbers without the headers ?
Using awk
:
ps -p 747 -o %cpu,%mem | awk 'NR>1'
Using sed
:
ps -p 747 -o %cpu,%mem | sed 1d