I want to exclude processes with CPU=0.0 from result of ps aux
command. Is it possible without any perversions (such as grep
)?
Asked
Active
Viewed 324 times
2 Answers
2
You could use awk:
ps aux | awk '{if ($3 != 0.0) print $0}'
This will include headers since the header is != "0.0"
If you're not familiar with the syntax, this awk command will test the third element in each line (split by " " space, by default) to see if it's not "0.0". If it isn't then it will print the entire line ($0).

JNevill
- 46,980
- 4
- 38
- 63
1
ps aux | awk '$3!=0.0 {print}'
the third field that is cpu is not 0.0
will print the whole line
if you want cpu usage in descending
order i.e high to low usage
ps aux --sort=-%cpu | awk '$3!=0.0 {print}'

Hackaholic
- 19,069
- 5
- 54
- 72