Tame `ps` Output: Focused Process Info with `awk`
Quick Tip
Tame `ps` Output: Focused Process Info with `awk`
Challenge: The output of the `ps` command can be overwhelmingly verbose, making it difficult to quickly find specific process information like PIDs, CPU usage, or memory consumption.
The Solution: Leverage `awk` to filter and format the `ps` command output for precisely what you need.
ps aux | awk '{print "PID: " $2 ", User: " $1 ", CPU: " $3 "%, Mem: " $4 "%"}'
Why it works: `ps aux` provides a comprehensive process listing. `awk` then processes each line, using default whitespace as a delimiter to extract and print specific fields in a user-defined format.
Pro-Tip: To find a process by name, you can pipe `ps aux` to `grep` first, then pipe that to `awk`. For example: `ps aux | grep nginx | awk ‘{print “PID: ” $2 “, CPU: ” $3 “%, Mem: ” $4 “%”}’`
Linux Tips & Tricks | © ngelinux.com | 7/4/2026
