Master `ps` Output: Focused Process Info with `awk`

Quick Tip

Master `ps` Output: Focused Process Info with `awk`

Challenge: The default `ps aux` or `ps -ef` output can be overwhelming, containing a lot of information you might not need when trying to quickly identify specific processes or their resource usage.

The Solution: Leverage the power of `awk` to parse and filter the output of `ps` for targeted information.

ps aux | awk '{if ($1 == "USER" || $2 ~ /^PID/) print; else if ($2 ~ /^[0-9]+$/ && $11 ~ /MY_PROCESS_NAME/) print}'

Why it works: This command uses `awk` to print the header line (usually USER and PID) and then filters for processes whose PID is a number and whose command name (the 11th field by default in `ps aux` output) matches “MY_PROCESS_NAME”. You can customize the fields and the matching criteria.

Pro-Tip: To see only the process ID (PID) and command name, use: ps aux | awk '{if ($1 == "USER" || $2 ~ /^PID/) print $2, $11; else if ($2 ~ /^[0-9]+$/ && $11 ~ /MY_PROCESS_NAME/) print $2, $11}'

Linux Tips & Tricks | © ngelinux.com | 5/24/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments