Taming `ps` Output: Focused Process Info with `awk`
Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The `ps` command can produce a lot of output, making it difficult to quickly find specific information about running processes. You might want to see just the command name, PID, and CPU usage, for example.
The Solution: Pipe the output of `ps` to `awk` and specify the fields you want to display.
ps aux | awk '{print $1, $2, $3, $4, $11}'
Why it works: `ps aux` provides a comprehensive list of running processes. `awk` then parses each line, and by specifying field numbers (e.g., $1 for user, $2 for PID, $3 for %CPU, $4 for %MEM, and $11 for the command), we can extract and display only the desired information in a clean, tabular format.
Pro-Tip: To make this even more readable, you can add headers by using `BEGIN` in `awk`: ps aux | awk 'BEGIN {print "USER PID %CPU %MEM COMMAND"} {print $1, $2, $3, $4, $11}'
Linux Tips & Tricks | © ngelinux.com | 5/30/2026
