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, displaying a vast amount of information about running processes. It’s often difficult to quickly find specific details like CPU usage, memory consumption, or the full command line for a particular process.

The Solution: Leverage `awk` to filter and format the `ps` output, allowing you to precisely extract the information you need.

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

Why it works: This command uses `ps aux` to list all processes with detailed information and then pipes the output to `awk`. `awk` processes the input line by line, and in this case, it’s configured to print specific columns: $1 (USER), $2 (PID), $3 (%CPU), $4 (%MEM), and $11 (COMMAND). You can customize these column numbers to display any `ps` output fields you desire.

Pro-Tip: To see processes sorted by CPU usage, you can use `ps aux –sort=-%cpu | awk ‘{print $1, $2, $3, $4, $11}’`.

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

0 0 votes
Article Rating
Exit mobile version