Tame Your Processes: Focused `ps` Output with `awk`
Quick Tip
Tame Your Processes: Focused `ps` Output with `awk`
Challenge: The standard `ps` command often outputs a large amount of information about running processes, making it difficult to quickly find specific details like the exact command, CPU usage, or memory consumption.
The Solution: Leverage the power of `awk` to filter and format the output of `ps` for precise information extraction.
ps aux | awk '{print $2, $11, $3, $4}'
Why it works: This command pipes the output of `ps aux` (which shows all processes with user, CPU, and memory information) to `awk`. `awk` then processes each line, printing specific fields (column numbers) representing the PID ($2), command ($11), CPU usage ($3), and memory usage ($4). You can adjust the field numbers to display exactly what you need.
Pro-Tip: To sort processes by CPU usage in descending order, pipe the output to `sort -rnk 3` before `awk`: ps aux | sort -rnk 3 | awk '{print $2, $11, $3, $4}'
Linux Tips & Tricks | © ngelinux.com | 6/16/2026
