Site icon New Generation Enterprise Linux

Tame Your Processes: Focused `ps` Output with `awk`

Quick Tip

Tame Your Processes: Focused `ps` Output with `awk`

Challenge: The output of the ps aux command can be overwhelming, making it difficult to quickly find specific process information like CPU or memory usage for a particular application.

The Solution: Combine ps aux with awk to filter and format the output to display only the columns you need.

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

Why it works: awk is a powerful text-processing tool that can parse lines of text based on fields. Here, it first filters lines containing your process name and then prints only the PID (field 2), %CPU (field 4), and command name (field 11).

Pro-Tip: You can easily add more fields to the print statement, for example, $6 for %MEM, by modifying the awk command like: ps aux | awk '/[your_process_name]/ {print $2, $4, $6, $11}'

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

0 0 votes
Article Rating
Exit mobile version