Tame Your Processes: Focused `ps` Output with `awk`
Quick Tip
Tame Your Processes: Focused `ps` Output with `awk`
TITLE: Tame Your Processes: Focused `ps` Output with `awk`
Challenge: The default `ps` command can be overwhelming with a vast amount of information for running processes. Often, you only need to see specific details like PID, user, and command name for a particular process.
The Solution: Pipe the output of `ps aux` (or `ps -ef`) to `awk` to filter and format the output for precisely what you need.
ps aux | awk '{print $2, $1, $11}' | grep 'your_process_name'
Why it works: `awk` processes the output line by line, allowing you to specify which fields (columns) to print. In this example, `$2` is the PID, `$1` is the user, and `$11` is typically the command name. `grep` then filters these results for your specific process.
Pro-Tip: For more complex filtering or to create custom headers, you can use `awk`’s `BEGIN` and `END` blocks to define initial and final actions, respectively. For example, to add headers: `ps aux | awk ‘BEGIN {print “PID\tUSER\tCOMMAND”} {print $2 “\t” $1 “\t” $11}’ | grep ‘your_process_name’`
Linux Tips & Tricks | © ngelinux.com | 5/17/2026
