Tame Your Processes: Focused `ps` Output with `awk`
Quick Tip
Tame Your Processes: Focused `ps` Output with `awk`
Challenge: The standard `ps aux` output can be overwhelming with a lot of information. Often, you just need to quickly identify specific processes based on certain criteria, like their command name or user.
The Solution: Combine the power of `ps` with `awk` for precise filtering and formatting of process information.
ps aux | awk '/nginx/ {print $1, $2, $11}'
Why it works: `ps aux` lists all running processes with detailed information. `awk` then processes this output line by line, and the `/nginx/` pattern filters for lines containing “nginx”. For those matching lines, it prints the user (field 1), PID (field 2), and the command (field 11).
Pro-Tip: Use `awk`’s conditional logic to create more complex filters. For example, `ps aux | awk ‘$1 == “root” && $11 ~ /sshd/ {print $2, $11}’` will show PIDs and commands for all `sshd` processes run by the ‘root’ user.
Linux Tips & Tricks | © ngelinux.com | 5/27/2026
