Master `ps` Output with Custom `awk` Formatting

Quick Tip

Master `ps` Output with Custom `awk` Formatting

Challenge: The standard output of the `ps` command can be overwhelming, often displaying more information than you need when trying to identify specific processes. You want to quickly and efficiently extract only the most relevant details.

The Solution: Combine `ps` with `awk` to precisely select and format the columns you want to see. For example, to see the PID, user, and command of all running processes, use:

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

Why it works: `ps aux` lists all processes with detailed information. `awk` then processes this output line by line, and `'{print $2, $1, $11}’` tells `awk` to print the second, first, and eleventh fields (which typically correspond to PID, USER, and COMMAND respectively) from each line, effectively filtering and reordering the output to your preference.

Pro-Tip: Use `ps -eo pid,user,command` for a more direct way to specify columns, then pipe to `awk` if further formatting is needed.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments