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 overwhelmingly verbose, making it difficult to quickly find specific process information like CPU usage, memory, or command line arguments.

The Solution: Combine `ps` with `awk` to filter and format the output for precisely the information you need.

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

Why it works: `ps aux` provides a comprehensive snapshot of running processes. `awk` then allows us to select specific columns by their position (e.g., `$1` for USER, `$2` for PID, `$4` for %CPU, `$11` for COMMAND) and print them in a clean, tailored format.

Pro-Tip: For a real-time, continuously updating view of the top 5 CPU-consuming processes, try: ps aux --sort=-%cpu | head -n 6 | awk '{print $1, $2, $4, $11}'

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

0 0 votes
Article Rating
Exit mobile version