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 overwhelming, showing a lot of unnecessary information when you’re trying to quickly identify specific processes and their resource usage.

The Solution: Leverage awk to filter and format the output of ps for a clean, targeted view of the processes you care about.

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

Why it works: This command uses awk to select and print specific columns from the ps aux output. In this example, it extracts the PID (column 2), the command name (column 11), CPU usage (column 3), and Memory usage (column 4). You can easily adjust the column numbers to display different process information.

Pro-Tip: To view processes owned by a specific user, use ps -u [username] -o pid,comm,pcpu,pmem and then pipe that to awk if further formatting is needed.

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

0 0 votes
Article Rating
Exit mobile version