Site icon New Generation Enterprise Linux

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

Quick Tip

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

Challenge: The output of the `ps` command can be overwhelming, making it difficult to quickly find the specific process information you need, such as the process ID (PID), command name, and CPU usage.

The Solution: Leverage `awk` to filter and format the output of `ps` to display only the columns you care about.

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

Why it works: `ps aux` provides a detailed snapshot of all running processes. `awk` then processes this output line by line, printing specific fields (columns) based on their numerical position. In this example, `$2` is the PID, `$11` is the command, and `$3` is the CPU percentage.

Pro-Tip: You can easily change the fields you display by modifying the numbers after the dollar sign in the `awk` command. For example, to see the user, PID, and memory usage, use ps aux | awk '{print $1, $2, $4}'.

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

0 0 votes
Article Rating
Exit mobile version