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

Quick Tip

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

Challenge: The output of the `ps` command can be overwhelmingly verbose, making it difficult to quickly find specific process information like CPU usage, memory footprint, or parent process ID.

The Solution: Combine `ps` with `awk` to filter and format the output for clarity.

ps aux | awk '{printf "%-10s %-5s %-5s %-5s %-10s %-s\n", $1, $2, $3, $4, $6, $11}'

Why it works: `ps aux` provides a comprehensive list of processes. `awk` then processes this output line by line, using `printf` to select and format specific fields (username, PID, %CPU, %MEM, RSS, command) into a more readable columnar format.

Pro-Tip: To sort the output by memory usage (descending), pipe the `awk` output to `sort -k5 -nr`. For CPU usage, use `sort -k4 -nr`.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments