Site icon New Generation Enterprise Linux

Taming `ps` Output with `awk` for Focused Process Information

Quick Tip

Taming `ps` Output with `awk` for Focused Process Information

Challenge: The output of the `ps` command can be overwhelming, especially when you’re trying to find specific information about running processes. You often end up piping it through `grep`, which can be cumbersome.

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

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

Why it works: `awk` is a powerful text-processing tool that can parse lines based on fields (columns). By specifying the desired column numbers (in this case, 1 for USER, 2 for PID, 4 for %CPU, and 11 for COMMAND), you can quickly extract and display only the relevant information, making your process monitoring much more efficient.

Pro-Tip: For a more readable header, you can combine `ps aux` with `head -n 1` for the header and then pipe that to `awk` as well, or use `ps -eo user,pid,%cpu,command` which is often more direct.

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

0 0 votes
Article Rating
Exit mobile version