Site icon New Generation Enterprise Linux

Supercharge Your `ps` Output with Custom `awk` Formatting

Quick Tip

Supercharge Your `ps` Output with Custom `awk` Formatting

Challenge: The default output of the `ps` command can be noisy and difficult to parse for specific process information. You need a way to extract and format exactly the columns you care about.

The Solution: Utilize `awk` to filter and format the output of `ps` for targeted process information.

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

Why it works: The `ps aux` command provides detailed process information. `awk` then processes this output line by line, and the `{print $1, $2, $11}` part tells `awk` to print only the first, second, and eleventh fields (typically USER, PID, and COMMAND, respectively) for each process.

Pro-Tip: Use `ps -eo user,pid,command` for a more direct way to specify columns, but `awk` offers greater flexibility for more complex filtering and transformations.

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

0 0 votes
Article Rating
Exit mobile version