Taming `ps` Output: Focused Process Info with `awk`
Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The standard `ps` command can output a lot of information about running processes, making it difficult to quickly find specific details like the CPU or memory usage of a particular process by name.
The Solution: Pipe the output of `ps` to `awk` to filter and display only the columns you need, focusing on the process name, PID, CPU%, and MEM%.
ps aux | awk '/process_name/ {print $1, $2, $3, $4}'
Why it works: `ps aux` provides a comprehensive view of all processes. `awk` then acts as a powerful text-processing tool, searching for lines containing ‘process_name’ and printing specific fields (User, PID, %CPU, %MEM) based on their column position.
Pro-Tip: You can replace ‘process_name’ with a more specific name or a regular expression for more precise filtering. For example, `ps aux | awk ‘/nginx/ {print $2, $3, $4}’` would show PID, %CPU, and %MEM for all nginx processes.
Linux Tips & Tricks | © ngelinux.com | 6/3/2026
