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 often be overwhelmingly verbose, making it difficult to quickly find the specific process information you need.

The Solution: Combine `ps` with `awk` to filter and display only the columns you’re interested in.

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

Why it works: `awk` is a powerful text-processing tool that can parse lines based on fields (columns). Here, we’re telling `awk` to print only the 1st (user), 2nd (PID), 4th (CPU usage), and 11th (command) fields from the `ps aux` output.

Pro-Tip: You can customize the `awk` script to select any columns from `ps` output. Use `ps aux –sort=-%cpu` to sort by CPU usage in descending order before piping to `awk`.

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

0 0 votes
Article Rating
Exit mobile version