Site icon New Generation Enterprise Linux

Taming `ps` Output: Focused Process Info with `awk`

Quick Tip

Taming `ps` Output: Focused Process Info with `awk`

Challenge: The output of the `ps` command can be overwhelming when you’re trying to find specific processes or information. You often have to scroll through many columns you don’t need.

The Solution: Combine `ps` with `awk` to precisely select and display only the columns you care about, making process monitoring much more efficient.

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

Why it works: `ps aux` provides a detailed snapshot of all running processes. `awk` then processes this output line by line, printing only the first field (USER), second field (PID), and eleventh field (COMMAND), effectively filtering out unnecessary information.

Pro-Tip: For RHEL/Ubuntu systems, you can also use `ps -eo user,pid,comm` for a similar, more direct approach to selecting columns without relying on `awk`’s field numbering.

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

0 0 votes
Article Rating
Exit mobile version