Site icon New Generation Enterprise Linux

Taming `ps` Output with Custom `awk` Formatting

Quick Tip

Taming `ps` Output with Custom `awk` Formatting

Challenge: The standard output of the ps command can be overwhelming, especially when you need to quickly identify specific processes based on user, CPU usage, or memory consumption. Parsing this output manually is tedious and error-prone.

The Solution: Combine ps with awk to filter and format the output precisely to your needs.

ps aux | awk '$1 == "your_user" && $4 > 10.0 { print $0 }'

Why it works: This command uses ps aux to list all processes with detailed information. awk then processes this output line by line. '$1 == "your_user"' filters for processes owned by ‘your_user’, and '$4 > 10.0' further filters for those consuming more than 10.0% CPU. The { print $0 } then prints the entire matching line.

Pro-Tip: To see only the PID and command name for these processes, use ps aux | awk '$1 == "your_user" && $4 > 10.0 { print $2, $11 }'.

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

0 0 votes
Article Rating
Exit mobile version