Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The `ps` command is powerful, but its output can be overwhelming. Often, you need to filter and extract specific information about running processes, like CPU usage, memory consumption, or command arguments, in a clean and structured way.
The Solution: Leverage `awk` to precisely format and filter `ps` output.
ps aux | awk '{printf "%-10s %-10s %-10s %-5s %s\n", $1, $2, $3, $4, $11}'
Why it works: `ps aux` provides a comprehensive snapshot of running processes. `awk` then processes this output line by line, using `printf` to format specific columns (`$1` for user, `$2` for PID, `$3` for CPU%, `$4` for MEM%, and `$11` for the command itself) into a more readable and organized table.
Pro-Tip: To filter for a specific process, pipe the `awk` output to `grep`. For example, `ps aux | awk ‘{printf “%-10s %-10s %-10s %-5s %s\n”, $1, $2, $3, $4, $11}’ | grep ‘nginx’`
Linux Tips & Tricks | © ngelinux.com | 7/3/2026
