Site icon New Generation Enterprise Linux

Master `ps` with `awk` for Focused Process Information

Quick Tip

Master `ps` with `awk` for Focused Process Information

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 user or process name.

The Solution: Combine `ps` with `awk` for precise filtering and formatting of process information.

ps aux | awk '/my_process_name/ {print $1, $2, $3, $4, $11}'

Why it works: `awk` allows you to specify patterns to match lines (e.g., `/my_process_name/`) and then print only the desired fields (columns) from those matching lines. In this example, it prints the User, PID, %CPU, %MEM, and Command.

Pro-Tip: To sort processes by CPU usage, use `ps aux –sort=-%cpu | head -n 10` to see the top 10 CPU-consuming processes.

Linux Tips & Tricks | © ngelinux.com | 5/11/2026

0 0 votes
Article Rating
Exit mobile version