Site icon New Generation Enterprise Linux

Taming `ps` Output with Custom `awk` Formatting

Quick Tip

Taming `ps` Output with Custom `awk` Formatting

Challenge: The default output of the ps command can be verbose and hard to parse when you’re looking for specific process information like CPU usage or memory consumption across many processes.

The Solution: Leverage awk to filter and format the output of ps for targeted information retrieval.

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

Why it works: This command pipes the comprehensive output of ps aux (all processes, user-oriented format) to awk. awk then selects and prints specific columns: User (1), PID (2), %CPU (3), %MEM (4), and Command (11), giving you a cleaner, more focused view.

Pro-Tip: You can easily customize the columns by changing the numbers within the curly braces (e.g., '{print $2, $5}' to show PID and TTY) or add filtering for specific processes.

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

0 0 votes
Article Rating
Exit mobile version