Quick Tip
Taming `ps` Output with `awk` for Focused Process Info
Challenge: The output of the `ps` command can be overwhelming when you’re trying to find specific process information quickly. Piping it to `grep` can sometimes be cumbersome, especially when you need to filter based on multiple criteria.
The Solution: Use `awk` to precisely select and format the columns you need from the `ps` output, making it much easier to find the information you’re looking for.
ps aux | awk '$1 == "youruser" && $11 ~ /your_process_name/ { print $2, $11, $12 }'
Why it works: `awk` processes the `ps` output line by line. We’re telling `awk` to only print the process ID ($2), command name ($11), and its arguments ($12) if the first field ($1, the user) is “youruser” and the command name ($11) contains “your_process_name”. This provides a highly targeted and clean output.
Pro-Tip: You can easily extend this to include other fields by adding their corresponding `$N` numbers to the `print` statement. For example, to also see the CPU usage, add `$3` to the print list: print $2, $3, $11, $12.
Linux Tips & Tricks | © ngelinux.com | 5/25/2026
