Site icon New Generation Enterprise Linux

Taming Process Sprawl: Focused `ps` Output with `awk`

Quick Tip

Taming Process Sprawl: Focused `ps` Output with `awk`

Challenge: The output of the `ps` command can be overwhelmingly verbose when you’re trying to find specific process information. You need a quick way to filter and display only the crucial details.

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

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

Why it works: `awk` allows you to specify which fields (columns) from the `ps` output you want to display. Here, we’re selecting the User (column 1), PID (column 2), %CPU (column 4), and the Command (column 11), giving you a concise overview.

Pro-Tip: To make it even more readable, you can add headers using `echo` and `awk`’s `printf` for formatted output. For example: echo "USER PID %CPU COMMAND"; ps aux | awk '{print $1, $2, $4, $11}'

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

0 0 votes
Article Rating
Exit mobile version