Master `ps` Output with Custom `awk` Formatting
Quick Tip
Master `ps` Output with Custom `awk` Formatting
Challenge: The default output of the `ps` command can be verbose and difficult to parse for specific process information. You often need to sift through many columns to find what you’re looking for.
The Solution: Leverage `awk` to select and format the exact columns you need from the `ps` command output.
ps aux | awk '{print $1, $2, $11}'
Why it works: This command pipes the output of `ps aux` (which provides a comprehensive list of running processes) to `awk`. `awk` then prints only the first ($1), second ($2), and eleventh ($11) fields, which typically correspond to the USER, PID, and COMMAND respectively. This dramatically simplifies log analysis and script development.
Pro-Tip: To sort processes by CPU usage (descending), you can use: `ps aux –sort=-%cpu | head -n 10`
Linux Tips & Tricks | © ngelinux.com | 5/27/2026
