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 incredibly verbose, making it difficult to quickly find specific information about running processes. You often want to see only a few key fields.

The Solution: Pipe the output of ps to awk to select only the columns you need.

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

Why it works: awk is a powerful text-processing tool that excels at field manipulation. By default, it splits lines into fields based on whitespace, and `'{print $1, $2, $4, $11}’` tells it to print the 1st, 2nd, 4th, and 11th fields (typically USER, PID, %CPU, and COMMAND) from each line of the ps aux output.

Pro-Tip: Use ps -eo user,pid,%cpu,command for a more direct way to specify output columns without needing awk for simple cases.

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

0 0 votes
Article Rating
Exit mobile version