Site icon New Generation Enterprise Linux

Boost `ps` Output Readability with Custom `awk` Formatting

Quick Tip

Boost `ps` Output Readability with Custom `awk` Formatting

Challenge: The default output of the `ps` command can be verbose and difficult to parse when you need to quickly extract specific process information.

The Solution: Leverage `awk` to reformat `ps` output for clearer, more targeted information.

ps aux | awk '{print "PID: " $2 ", USER: " $1 ", %CPU: " $3 ", %MEM: " $4 ", COMMAND: " $11}'

Why it works: `awk` is a powerful pattern scanning and processing language that allows you to manipulate text by fields. Here, we’re telling `awk` to print specific fields from the `ps aux` output, clearly labeling each piece of information.

Pro-Tip: For even more control, you can use `ps -eo pid,user,%cpu,%mem,cmd` and then pipe that to `awk`.

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

0 0 votes
Article Rating
Exit mobile version