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 output of the `ps` command can be overwhelming when you’re trying to find specific information about processes, such as CPU usage, memory, or process IDs (PIDs).

The Solution: Use `awk` to filter and format the `ps` output to show only the columns you need.

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

Why it works: This command pipes the output of `ps aux` (which provides a comprehensive view of running processes) to `awk`. `awk` then processes each line and prints only the specified fields: the username ($1), PID ($2), %CPU ($4), and command ($11), making the output much more readable and targeted.

Pro-Tip: To sort the output by CPU usage (descending), you can pipe the `awk` output to `sort -rnk3` (for the 3rd column, which is %CPU in this case): ps aux | awk '{print $1, $2, $4, $11}' | sort -rnk3

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

0 0 votes
Article Rating
Exit mobile version