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 process information than you typically need. Filtering and extracting specific details can be cumbersome.

The Solution: Leverage `awk` to precisely select and format the columns you care about from the `ps` command’s output.

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

Why it works: This command pipes the output of `ps aux` (which shows all running processes with user, CPU, and memory usage) to `awk`. `awk` then processes each line, printing only the first, second, and eleventh fields, typically representing the USER, PID, and COMMAND respectively, giving you a cleaner, more focused view.

Pro-Tip: To include a header, you can use `ps aux | awk ‘NR==1 {print “USER PID COMMAND”} NR>1 {print $1, $2, $11}’`.

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

0 0 votes
Article Rating
Exit mobile version