Taming `ps` Output: Focused Process Info with `awk`
Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The `ps` command often produces a lot of information, making it hard to quickly find specific process details like PID, CPU usage, or memory. Filtering and formatting this output can be cumbersome.
The Solution: Leverage the power of `awk` to precisely select and format the columns you need from the `ps` output.
ps aux | awk '{print $1, $2, $4, $11}'
Why it works: `awk` is a powerful text-processing tool that can parse lines based on fields (columns). By default, it uses whitespace as a delimiter, allowing us to easily select specific columns (like User, PID, %CPU, and Command Name in this example) from the comprehensive `ps aux` output.
Pro-Tip: You can easily reorder or rename these columns within the `awk` command using `printf` for more readable output. For instance, `ps aux | awk ‘{printf “User: %-15s PID: %5s %%CPU: %4s Command: %s\n”, $1, $2, $4, $11}’` provides a nicely formatted output.
Linux Tips & Tricks | © ngelinux.com | 5/11/2026
