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 overwhelmingly verbose, making it difficult to quickly find specific process information like CPU usage, memory, or command name.

The Solution: Combine `ps` with `awk` to filter and format the output for exactly what you need.

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

Why it works: `ps aux` provides a detailed snapshot of all running processes. `awk` then processes this output line by line, printing only the specified columns (User, PID, %CPU, and Command) based on their typical positional order.

Pro-Tip: To sort processes by CPU usage in descending order, pipe the output to `sort -rnk3` (e.g., ps aux | awk '{print $1, $2, $4, $11}' | sort -rnk3).

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

0 0 votes
Article Rating
Exit mobile version