Site icon New Generation Enterprise Linux

Master `ps` Output with Custom `awk` Formatting

Quick Tip

Master `ps` Output with Custom `awk` Formatting

Challenge: The default output of the ps command can be verbose and difficult to parse for specific process information, especially when you need to quickly identify key metrics like CPU usage, memory, or command name.

The Solution: Leverage the power of awk to filter and format the output of ps for cleaner, more targeted information.

ps aux | awk '{print "PID: " $2 ", CPU: " $3 "%" ", MEM: " $4 "%" ", COMMAND: " $11}'

Why it works: This command pipes the output of ps aux (which shows all processes for all users with CPU and memory utilization) to awk. awk then processes each line, printing only the Process ID (PID), CPU percentage, Memory percentage, and the command name, making the output significantly more readable.

Pro-Tip: To see only processes belonging to a specific user, add a condition like: ps aux | awk -v user="your_username" '$1 == user {print "PID: " $2 ", COMMAND: " $11}'

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

0 0 votes
Article Rating
Exit mobile version