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 output of the `ps` command can be verbose and difficult to parse when you’re looking for specific process information like CPU usage, memory, or parent process ID (PPID).

The Solution: Combine `ps` with `awk` to filter and display only the columns you need, making it much easier to pinpoint the exact information you’re after.

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

Why it works: The `ps aux` command lists all processes with user, CPU percentage, memory percentage, and command. `awk` then processes this output line by line, printing only the specified fields (user, PID, %CPU, and command name) separated by spaces.

Pro-Tip: To also see the parent process ID (PPID), you can use `ps -eo user,pid,ppid,%cpu,%mem,comm | awk ‘{print $1, $2, $3, $4, $5, $6}’`. The `-eo` option allows you to specify the exact output format.

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

0 0 votes
Article Rating
Exit mobile version