Master `ps` Output: Focused Process Info with `awk`

Quick Tip

Master `ps` Output: Focused Process Info with `awk`

Challenge: The output of the `ps` command can be overwhelming, especially when trying to find specific information about running processes. You might want to see just the PID, command, and CPU/memory usage for a particular process.

The Solution: Combine `ps` with `awk` to precisely extract the information you need.

ps aux | awk '/[p]rocess_name/ {print $2, $11, $3, $4}'

Why it works: `ps aux` provides a comprehensive list of running processes. `awk` then filters this output, searching for lines containing ‘process_name’ (use a pattern that uniquely identifies your process, enclosed in `/ /`). The subsequent `{print $2, $11, $3, $4}` specifies which columns to display: PID (column 2), command (column 11), CPU% (column 3), and MEM% (column 4). The `[p]` in the pattern is a common `awk` trick to prevent `awk` itself from matching the `awk` command in the output.

Pro-Tip: Use `ps auxf | awk ‘/[p]rocess_name/ {print $1, $2, $11}’` to see a process tree with its PID and command.

Linux Tips & Tricks | © ngelinux.com | 6/22/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted