How to get rid of the headers in a ps command in Mac OS X ?

Viewed 18584

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 ?

6 Answers

You can use below command and you don't need to add pcpu="", it worked for me:

ps -Ao pcpu=

Use $ps - | grep -v <header_name>

Related