Site icon New Generation Enterprise Linux

Tame Your Processes: Focused `ps` Output with `awk`

Quick Tip

Tame Your Processes: Focused `ps` Output with `awk`

Challenge: The output of the `ps` command can be overwhelming, especially on busy systems. You often need to filter and display specific process information efficiently.

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

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

Why it works: `ps aux` provides detailed information about all running processes. `awk` then processes this output line by line, printing only the specified columns (username, PID, and command in this example). You can easily change the column numbers to display other process attributes.

Pro-Tip: Use `ps -eo pid,ppid,cmd,%cpu,%mem` to explicitly define the columns you want, then pipe to `awk` for even finer control and cleaner output.

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

0 0 votes
Article Rating
Exit mobile version