Taming Process Output: Focused `ps` with `awk`
Quick Tip
Taming Process Output: Focused `ps` with `awk`
Challenge: The output of the `ps` command can be overwhelmingly verbose when you’re trying to pinpoint specific process information like PID, CPU usage, or memory consumption.
The Solution: Combine `ps` with `awk` for precise control over the displayed columns.
ps aux | awk '{print $1, $2, $3, $4, $11}'
Why it works: `awk` can parse the output of `ps` (which is typically space-delimited) and print only the specific fields you’re interested in, based on their column number. In this example, it prints the username, PID, %CPU, %MEM, and the command name.
Pro-Tip: For a more dynamic selection of columns, you can use `ps aux –sort=-%cpu | head -n 10 | awk ‘{print $1, $2, $3, $4, $11}’` to get the top 10 CPU-consuming processes.
Linux Tips & Tricks | © ngelinux.com | 5/26/2026
