Site icon New Generation Enterprise Linux

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

Quick Tip

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

Challenge: The default output of the ps command can be overwhelming, especially on busy systems. You often need to filter and display specific process information like PID, user, and CPU usage.

The Solution: Pipe the output of ps aux (or ps -ef) to awk to precisely select and format the columns you need.

ps aux | awk '{print "PID: " $2 ", User: " $1 ", CPU: " $3 "%"}'

Why it works: awk processes text line by line and allows you to access fields (columns) by their number. By piping ps output, you can easily extract and rearrange this data for better readability.

Pro-Tip: Use ps -eo pid,user,%cpu,command to specify output columns directly in ps, and then pipe to awk if further formatting is required.

Linux Tips & Tricks | © ngelinux.com | 6/20/2026

0 0 votes
Article Rating
Exit mobile version