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 difficult to parse for specific process information, making it hard to quickly identify critical metrics like CPU usage, memory, or command names.

The Solution: Use `awk` to filter and format the output of `ps` to display only the columns you need, in the order you prefer.

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

Why it works: This command pipes the output of `ps aux` (which shows all processes for all users with CPU and memory usage) to `awk`. `awk` then processes each line, printing specific fields (user, PID, %CPU, %MEM, and command) separated by tabs (`\t`).

Pro-Tip: For even finer control, create a shell function or alias that predefines your desired `awk` formatting for `ps`. For example: alias psmini='ps aux | awk '\''{print $1 "\t" $2 "\t" $3 "\t" $4 "\t" $11}'\'''

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments