Site icon New Generation Enterprise Linux

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

Quick Tip

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

Challenge: The standard output of the `ps` command can be overwhelming, often displaying more information than you need, making it difficult to quickly find specific process details.

The Solution: Use `awk` to filter and format the output of `ps` to display only the essential columns.

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

Why it works: This command pipes the output of `ps aux` (which provides a detailed snapshot of running processes) to `awk`. `awk` then processes each line, printing only the first field (User), second field (PID), and eleventh field (Command), effectively creating a cleaner, more focused view.

Pro-Tip: To sort the output by CPU usage (descending), pipe the result to `sort -rnk 2` (replace `2` with the column number for CPU usage if you’ve changed the `awk` fields). For example: ps aux | awk '{print $1, $2, $3, $11}' | sort -rnk 3 to sort by CPU usage.

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

0 0 votes
Article Rating
Exit mobile version