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

Quick Tip

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

Challenge: The output of the `ps` command can be overwhelming, showing a vast amount of information about running processes. Often, you only need specific details like the process name, PID, and CPU/memory usage.

The Solution: Combine `ps` with `awk` to precisely filter and format the process information.

ps aux | awk 'NR==1{print $0} NR>1{print $1, $2, $3, $4, $11}'

Why it works: `ps aux` lists all processes with detailed information. `awk` then processes this output line by line. `NR==1` prints the header row as is, while `NR>1` prints only the 1st (user), 2nd (PID), 3rd (CPU%), 4th (MEM%), and 11th (command) fields for subsequent lines, giving you a concise, relevant view.

Pro-Tip: You can easily adjust the field numbers in the `awk` command to display other `ps` columns, such as the TTY (field 6) or STAT (field 8).

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted