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, especially when you need to quickly identify key metrics like CPU or memory usage for a particular application.
The Solution: Combine `ps` with `awk` to selectively display and format process information.
ps aux | awk '{print $1, $2, $4, $11}'
Why it works: This command uses `ps aux` to list all running processes with detailed information. `awk` then processes this output, printing only the specified fields: User (1), PID (2), %CPU (4), and Command (11). This creates a cleaner, more targeted view of your processes.
Pro-Tip: To sort processes by CPU usage (descending), you can pipe the `awk` output to `sort -rnk3` (where `3` refers to the third column, %CPU in this example, assuming you’ve adjusted the `awk` output accordingly).
Linux Tips & Tricks | © ngelinux.com | 5/9/2026
