Tame Your `ps` Output: Focused Process Info with `awk`
Quick Tip
Tame Your `ps` Output: Focused Process Info with `awk`
Challenge: The default output of the `ps` command can be overwhelming, showing far more information than you might need. It’s often difficult to quickly find specific processes based on their resource usage or command line arguments.
The Solution: Combine `ps` with `awk` to filter and display precisely the process information you need.
ps aux | awk '$11 ~ /nginx/ { print $2, $4, $11 }'
Why it works: This command first lists all running processes with `ps aux`. Then, `awk` is used to filter these processes. In this example, `$11` refers to the command name (the 11th field in `ps aux` output), and `~ /nginx/` checks if the command name contains “nginx”. If it does, `awk` prints the process ID (`$2`), CPU usage (`$4`), and the command name (`$11`). You can easily adapt the `awk` pattern and the fields to print to suit your needs.
Pro-Tip: Use `ps -ef | awk ‘{ if ($8 ~ /sshd/) print $2, $8 }’` to find all `sshd` processes and their full command paths.
Linux Tips & Tricks | © ngelinux.com | 5/27/2026
