Taming `ps` Output: Focused Process Info with `awk`
Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The output of the ps aux command can be overwhelming when you need to quickly find specific information about processes, like their CPU or memory usage, or sort them by a particular metric.
The Solution: Combine ps with awk to filter and format the output for targeted analysis.
ps aux | awk '{print $1, $2, $3, $4, $11}' | sort -k3 -nr
Why it works: awk allows you to select specific columns (in this case, user, PID, %CPU, %MEM, and command) from the ps output. Then, sort -k3 -nr sorts this filtered output numerically (-n) in reverse (-r) based on the third column, which is %CPU, giving you a quick view of the top CPU-consuming processes.
Pro-Tip: To sort by memory usage instead, change the sort key to -k4 -nr.
Linux Tips & Tricks | © ngelinux.com | 5/15/2026
