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 overwhelming, showing far more information than you often need. Filtering it to see specific details about processes can be cumbersome.

The Solution: Use `awk` to precisely select and format the columns you’re interested in from the `ps` output.

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

Why it works: This command pipes the output of `ps aux` (which shows all processes for all users with detailed information) to `awk`. `awk` then processes each line, printing only the 1st, 2nd, 3rd, and 11th fields, which typically correspond to the user, PID, CPU usage, and command name, respectively.

Pro-Tip: For more control, you can use `ps -eo user,pid,pcpu,comm` to directly request specific columns from `ps` itself, often making `awk` unnecessary for simple filtering.

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

0 0 votes
Article Rating
Exit mobile version