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 and difficult to parse for specific process information. You often need to sift through many columns to find what you’re looking for.

The Solution: Leverage awk to precisely select and format the columns you need from the ps command.

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

Why it works: This command pipes the output of ps aux (which shows all running processes with user, CPU, and memory usage) to awk. awk then processes each line, printing only the first column (USER), second column (PID), and eleventh column (COMMAND), effectively filtering and reformatting the output to your desired fields.

Pro-Tip: For even more targeted output, you can add conditions to your awk script. For example, to see only processes owned by ‘root’: ps aux | awk '/^root\s+/ {print $1, $2, $11}'

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

0 0 votes
Article Rating
Exit mobile version