Streamline `ps` Output with Custom `awk` Formatting

Quick Tip

Streamline `ps` Output with Custom `awk` Formatting

Challenge: The default output of the `ps` command can be overwhelming, making it difficult to quickly find specific process information like CPU usage, memory consumption, or parent process ID.

The Solution: Combine `ps` with `awk` to selectively display and format the process information you need.

ps aux | awk '{printf "%-10s %-8s %-8s %s\n", $1, $4, $6, $11}'

Why it works: `ps aux` provides a comprehensive list of running processes. `awk` then processes this output line by line, using `printf` to format specific fields (user, %CPU, %MEM, and command name) into a more readable and condensed format. The `%-10s` etc. ensures left-aligned columns of specific widths.

Pro-Tip: Use `ps -eo pid,ppid,cmd,%cpu,%mem` for a more structured output that you can pipe to `awk` for even finer control over display order and formatting.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments