Site icon New Generation Enterprise Linux

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

Quick Tip

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

Challenge: When dealing with numerous processes, the standard `ps aux` or `ps -ef` output can be overwhelming. You often need to filter and present specific process information efficiently.

The Solution: Use `awk` to sculpt your `ps` output into exactly what you need.

ps aux | awk '/my_process_name/ {print $1, $2, $11}'

Why it works: This command pipes the output of `ps aux` (which lists all processes with user, PID, CPU, etc.) to `awk`. `awk` then processes each line, and the `/my_process_name/` pattern filters for lines containing “my_process_name”. For matching lines, `{print $1, $2, $11}` extracts and prints the username (field 1), PID (field 2), and the command name (field 11) from that line.

Pro-Tip: For even more targeted filtering, you can chain `grep` before `awk` or use more complex `awk` patterns for multiple conditions.

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

0 0 votes
Article Rating
Exit mobile version