Site icon New Generation Enterprise Linux

Tame `ps` Output with Custom `awk` Formatting

Quick Tip

Tame `ps` Output with Custom `awk` Formatting

Challenge: The default output of the `ps` command can be verbose and difficult to parse when you need specific process information quickly.

The Solution: Leverage `awk` to filter and format the output of `ps` to display only the columns you need.

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

Why it works: This command pipes the output of `ps aux` (which shows all processes with user, CPU, and memory usage) to `awk`. `awk` then processes each line, printing only the first (User), second (PID), and eleventh (Command) fields, providing a cleaner, more focused view.

Pro-Tip: To sort the output by PID, you can pipe the result to `sort -k2 -n`.

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

0 0 votes
Article Rating
Exit mobile version