Taming Process Sprawl: Focused `ps` Output with `awk`

Quick Tip

Taming Process Sprawl: Focused `ps` Output with `awk`

Challenge: When running `ps aux` or `ps -ef`, the output can be overwhelming, especially on busy systems. You often need to quickly filter and extract specific information like process ID (PID), command name, or CPU/memory usage.

The Solution: Leverage `awk` to precisely format and filter the `ps` output.

ps aux | awk '/[Cc]hrome/ {print $2, $11}'

Why it works: `awk` processes the output line by line. In this example, it first filters for lines containing “Chrome” (case-insensitive due to `[Cc]hrome`) and then prints the second field (PID) and the eleventh field (command name) from those matching lines.

Pro-Tip: For even finer control, you can create custom `ps` aliases in your `.bashrc` or `.zshrc` like: alias psgrep='ps aux | awk "/$1/ {print \$2, \$11}"'. Then, you can run psgrep Chrome to get the desired output.

Linux Tips & Tricks | © ngelinux.com | 6/22/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted