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 verbose and overwhelming, making it difficult to quickly find specific process information like PID, CPU usage, or command name.
The Solution: Combine `ps` with `awk` to filter and format the output for precisely what you need.
ps aux | awk 'NR==1 || $11 ~ /my_process_name/ {print $0}'
Why it works: `ps aux` provides a comprehensive list of running processes. `awk` then filters this output. `NR==1` ensures the header row is always printed, and `$11 ~ /my_process_name/` filters for lines where the eleventh field (typically the command name in `ps aux`) contains “my_process_name”. You can customize the fields printed by `awk` by specifying them, e.g., `print $1, $2, $11`.
Pro-Tip: For even more specific filtering, you can use `grep` before `awk` to pre-filter the process name, like `ps aux | grep my_process_name | awk ‘NR==1 || $0 {print $0}’`.
Linux Tips & Tricks | © ngelinux.com | 6/17/2026
