Taming `ps` Output: Focused Process Info with `awk`
Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The output of the `ps` command can be overwhelming, displaying a lot of information you might not need when troubleshooting or monitoring specific processes. It’s hard to quickly find the CPU or memory usage of a particular application.
The Solution: Combine `ps` with `awk` to filter and format the output for clarity.
ps aux | awk '{print $1, $2, $3, $4, $11}'
Why it works: `ps aux` provides a comprehensive list of running processes. `awk` then processes this output line by line, printing only the specified columns: user, PID, %CPU, %MEM, and the command name. This makes it significantly easier to scan for the information you need.
Pro-Tip: To sort processes by CPU usage, pipe the output to `sort -k3 -nr` (for descending numerical order on the 3rd column). For example: ps aux | awk '{print $1, $2, $3, $4, $11}' | sort -k3 -nr | head -n 10 to see the top 10 CPU-consuming processes.
Linux Tips & Tricks | © ngelinux.com | 6/3/2026
