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 when you’re trying to find specific process information, like the CPU and memory usage of a particular process. You often have to sift through a lot of columns and lines.

The Solution: Use `awk` to filter and display only the columns you need from the `ps` command.

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

Why it works: This command pipes the output of `ps aux` (which shows all processes for all users) to `awk`. `awk` then filters lines containing ‘process_name’ and prints only the specified columns (User, PID, %CPU, %MEM, and Command), making it much easier to read.

Pro-Tip: Replace ‘process_name’ with the actual name or a part of the name of the process you’re looking for. You can also adjust the column numbers ($1, $2, etc.) to display different information.

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

0 0 votes
Article Rating
Exit mobile version