Taming `ps` Output: Focused Process Info with `awk`
Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The `ps` command can sometimes produce an overwhelming amount of information, making it difficult to pinpoint specific processes based on desired attributes like user, CPU usage, or memory. You often need to sift through many columns that might not be immediately relevant.
The Solution: Leverage `awk` to filter and format the output of `ps` for precise process monitoring.
ps aux | awk '{print $1, $2, $3, $4, $11}' | grep 'my_process_name'
Why it works: This command first gets a comprehensive snapshot of running processes with `ps aux`. Then, `awk` is used to select and print only specific columns (User, PID, %CPU, %MEM, Command), and `grep` filters this concise output to show only lines containing ‘my_process_name’.
Pro-Tip: You can customize the column numbers in the `awk` command to display exactly the process information you need. For example, `awk ‘{print $1, $2, $6}’` would show User, PID, and the elapsed time of the process.
Linux Tips & Tricks | © ngelinux.com | 6/13/2026
