Taming `ps` Output: Focused Process Info with `awk`
Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The `ps` command often outputs a vast amount of information, making it difficult to quickly find specific process details like CPU usage, memory consumption, or the command name.
The Solution: Combine `ps` with `awk` to selectively display and format the information you need.
ps aux | awk '{print $1, $2, $4, $11}'
Why it works: `ps aux` provides a comprehensive listing of processes. `awk` then processes this output line by line, printing only the specified columns (user, PID, %CPU, and command name in this example) to create a cleaner, more readable output.
Pro-Tip: To sort processes by CPU usage in descending order, pipe the output to `sort -rnk 3` (where 3 is the column number for %CPU). Example: ps aux | awk '{print $1, $2, $4, $11}' | sort -rnk 3 | head -n 10
Linux Tips & Tricks | © ngelinux.com | 5/25/2026
