Site icon New Generation Enterprise Linux

Tame Your `ps` Output: Focused Process Info with `awk`

Quick Tip

Tame Your `ps` Output: Focused Process Info with `awk`

Challenge: The `ps` command often outputs a lot of information, making it hard to quickly find specific process details like PID, CPU usage, or memory consumption.

The Solution: Pipe the output of `ps` to `awk` for selective field extraction and formatting.

ps aux | awk '{print "PID: "$2", CPU: "$3"%, MEM: "$4"%, COMMAND: "$11}'

Why it works: `awk` allows you to process text line by line and extract specific columns (fields) based on their position. By default, fields are separated by whitespace, so you can easily grab the PID, CPU%, MEM%, and COMMAND from the `ps aux` output.

Pro-Tip: Use `ps -eo pid,pcpu,pmem,comm` for a more direct and often cleaner output format, then pipe to `awk` if further manipulation is needed.

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

0 0 votes
Article Rating
Exit mobile version