Site icon New Generation Enterprise Linux

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

Quick Tip

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

TITLE: Taming Process Sprawl: 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 CPU usage or memory consumption for a particular user or process name.

The Solution: Leverage `awk`’s powerful text processing capabilities to filter and format `ps` output for targeted information.

ps aux | awk '$1 == "your_username" { print $1, $2, $3, $4, $11 }'

Why it works: `ps aux` lists all running processes. `awk` then iterates through each line, and `$1 == “your_username”` filters for lines where the first field (username) matches your input. The `print` statement then selects and displays specific fields (username, PID, %CPU, %MEM, command) from the matching lines.

Pro-Tip: To find processes consuming high CPU, use `ps aux –sort=-%cpu | head -n 10` to see the top 10 CPU-hungry processes.

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

0 0 votes
Article Rating
Exit mobile version