Site icon New Generation Enterprise Linux

Taming `ps` Output with Custom `awk` Formatting

Quick Tip

Taming `ps` Output with Custom `awk` Formatting

Challenge: The default output of the `ps` command can be overwhelming, containing far more information than you often need for quick process status checks. Parsing and filtering this output manually can be tedious.

The Solution: Leverage `awk` to precisely select and format the columns you want from the `ps` command’s output.

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

Why it works: This command pipes the output of `ps aux` (which shows all processes for all users, with user-oriented format) to `awk`. `awk` then processes each line and prints only the specified columns: User (column 1), PID (column 2), %CPU (column 4), and the command name (column 11).

Pro-Tip: You can easily customize the columns by changing the numbers within the curly braces `{}` in the `awk` command to match your desired `ps` output fields. Use `ps auxf` for a tree-like view of processes if you need to see parent-child relationships.

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

0 0 votes
Article Rating
Exit mobile version