Tame Your Processes: Focused `ps` Output with `awk`

Quick Tip

Tame Your Processes: Focused `ps` Output with `awk`

Challenge: The `ps` command can sometimes be overwhelming with its verbose output, making it difficult to quickly find specific process information like CPU usage, memory, or command name.

The Solution: You can leverage the power of `awk` to filter and format the output of `ps` for targeted information.

ps aux | awk '{print $1, $2, $3, $4, $11}' | head -n 5

Why it works: This command pipes the output of `ps aux` (which shows all processes with user, CPU, memory, etc.) to `awk`. `awk` then prints specific columns (User, PID, %CPU, %MEM, and Command) from each line, allowing you to focus on the data you need. `head -n 5` displays the first 5 lines of the filtered output.

Pro-Tip: To see processes sorted by CPU usage, you can pipe `ps aux` to `sort -rnk 3 | awk ‘{print $1, $2, $3, $4, $11}’` (the ‘-rnk 3’ sorts numerically in reverse order on the 3rd column, which is %CPU).

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted