Site icon New Generation Enterprise Linux

Tame Your Processes: Focused `ps` Output with `awk`

Quick Tip

Tame Your Processes: Focused `ps` Output with `awk`

Challenge: The output of the `ps` command can often be overwhelming, showing far too much information when you’re just trying to find specific process details like PID, command, or CPU usage.

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

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

Why it works: `ps aux` provides a comprehensive snapshot of all running processes. `awk` then processes this output line by line, and by specifying column numbers (e.g., `$1` for USER, `$2` for PID, `$4` for %CPU, `$11` for COMMAND), you can extract and display only the relevant fields, making your process monitoring much more efficient.

Pro-Tip: Use `ps -eo pid,comm,%cpu,%mem,args` for a more direct way to specify columns without relying on positional numbers, which can sometimes change between `ps` versions.

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

0 0 votes
Article Rating
Exit mobile version