Site icon New Generation Enterprise Linux

Taming `ps` Output with Custom `awk` Formatting

Quick Tip

Taming `ps` Output with Custom `awk` Formatting

Challenge: The default output of the ps command can be overwhelming and difficult to parse when you need specific process information quickly. You might want to see only the command, PID, and CPU usage, for example.

The Solution: Leverage the power of awk to filter and format the output of ps. This allows you to display only the fields you need in a clear, structured way.

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

Why it works: The ps aux command provides a comprehensive list of running processes. awk then processes this output line by line, and with '{print $11, $2, $3}', it selects and prints the 11th field (command name), 2nd field (PID), and 3rd field (CPU percentage) from each line, giving you a clean, customized view.

Pro-Tip: To see only user, PID, and command for processes owned by your current user, use: ps -u $(whoami) -o pid,comm

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

0 0 votes
Article Rating
Exit mobile version