Taming Process Output: Focused `ps` with `awk`
Quick Tip
Taming Process Output: Focused `ps` with `awk`
Challenge: The standard `ps` command can sometimes be overwhelming with its verbose output, making it difficult to quickly identify specific process information like PIDs, CPU usage, or memory consumption.
The Solution: Pipe the output of `ps` to `awk` to select and format only the columns you need.
ps aux | awk '{printf "%-10s %-30s %-5s %-5s %-10s %-10s %s\n", $1, $11, $3, $4, $5, $6, $7}'
Why it works: `ps aux` provides a comprehensive list of running processes. `awk` then processes this output line by line, using `printf` to format and display only the specified fields (username, command, %CPU, %MEM, VSZ, RSS, TTY, STAT). This allows for a highly customizable and readable process list.
Pro-Tip: You can easily customize the fields by changing the numbers in the `awk` command (e.g., `$2` for PID, `$4` for %CPU).
Linux Tips & Tricks | © ngelinux.com | 5/26/2026
