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

Quick Tip

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

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

The Solution: Combine ps with awk to filter and format the output, showing only the columns you need. For example, to see the PID, PPID, CPU percentage, and memory percentage for all running processes:

ps aux | awk '{print "PID: " $2 ", PPID: " $3 ", %CPU: " $4 ", %MEM: " $5}'

Why it works: ps aux provides detailed information for all processes. awk then processes this output line by line, using spaces as default delimiters to extract and format specific fields (columns) into a more readable and concise format.

Pro-Tip: You can customize the output further by specifying different columns or adding conditional logic within awk. For instance, to only show processes using more than 5% memory: ps aux | awk '$4 > 5.0 {print "PID: " $2 ", %MEM: " $4}'

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted