Site icon New Generation Enterprise Linux

Taming `ps`: Focused Process Info with `awk`

Quick Tip

Taming `ps`: Focused Process Info with `awk`

Challenge: The standard `ps aux` command provides a wealth of information about running processes, but it can be overwhelming and difficult to sift through when you need specific details like CPU usage, memory, and command name.

The Solution: Leverage `awk` with `ps` to precisely select and format the output you need.

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

Why it works: `awk` allows you to treat each line of output as records and each field (separated by whitespace by default) as an element. By specifying the fields you want (`$1` for USER, `$2` for PID, `$3` for %CPU, `$4` for %MEM, and `$11` for the command), you can create a tailored and concise view of your processes.

Pro-Tip: To sort processes by CPU usage in descending order, pipe the output to `sort -rnk3`.

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

0 0 votes
Article Rating
Exit mobile version