Site icon New Generation Enterprise Linux

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

Quick Tip

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

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

The Solution: Pipe the output of `ps aux` (or `ps -ef`) to `awk` to select and format only the columns you need.

ps aux | awk '{print $1 "\t" $2 "\t" $11}'

Why it works: `awk` is a powerful text-processing tool that excels at splitting lines into fields and manipulating them. By specifying the desired field numbers (e.g., $1 for USER, $2 for PID, $11 for COMMAND in `ps aux`), you can create a clean, targeted output.

Pro-Tip: To sort processes by CPU usage (descending), pipe the output through sort -rnk 3: ps aux | awk '{print $1 "\t" $2 "\t" $3 "\t" $11}' | sort -rnk 3 (adjust field number for CPU if needed).

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

0 0 votes
Article Rating
Exit mobile version