Supercharge `ps` Output with Custom `awk` Formatting
Quick Tip
Supercharge `ps` Output with Custom `awk` Formatting
Challenge: The default output of the `ps` command can be verbose and difficult to parse for specific process information. You often need to sift through many columns to find what you’re looking for.
The Solution: Combine `ps` with `awk` to extract and format precisely the process details you need.
ps aux | awk '{printf "%-10s %-5s %-5s %-s\n", $2, $3, $4, $11}'
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 PID (column 2), CPU usage (column 3), Memory usage (column 4), and the command name (column 11) in a clean, aligned format.
Pro-Tip: You can easily customize the columns by changing the numbers in the `awk` command (e.g., `$1` for User, `$6` for RSS, etc.) and adjusting the spacing in the `printf` statement.
Linux Tips & Tricks | © ngelinux.com | 6/3/2026
