Taming `ps` Output with `awk` for Focused Process Information
Quick Tip
Taming `ps` Output with `awk` for Focused Process Information
Challenge: When you run the `ps` command, the output can be overwhelming with many columns, making it difficult to find specific process details like PID, CPU usage, or memory. You often need to sift through a lot of irrelevant information.
The Solution: Use `awk` to filter and select only the columns you need from the `ps` output.
ps aux | awk '{print $1, $2, $3, $4, $11}'
Why it works: The `ps aux` command lists all running processes. We then pipe this output to `awk`, which is a powerful text-processing tool. `awk` processes the input line by line, and the expression `'{print $1, $2, $3, $4, $11}’` tells it to print the first, second, third, fourth, and eleventh fields (columns) of each line. These typically correspond to USER, PID, %CPU, %MEM, and COMMAND, respectively.
Pro-Tip: Use `ps -eo pid,user,%cpu,%mem,comm` for a more direct and often cleaner way to get specific columns without `awk`, if your `ps` implementation supports it.
Linux Tips & Tricks | © ngelinux.com | 5/23/2026
