Quick Tip
Master `ps` Output with Custom `awk` Formatting
Challenge: The default output of the ps command can be noisy and difficult to parse when you need specific process information like PID, CPU usage, or memory. You want to extract and format this data efficiently.
The Solution: Combine ps with awk to precisely select and format the columns you need.
ps aux | awk '{printf "%-10s %-8s %-5s %-5s %-10s %s\n", $1, $2, $3, $4, $5, $11}'
Why it works: ps aux provides a comprehensive list of processes. awk then processes each line, using printf to format specific fields ($1 for USER, $2 for PID, etc.) into aligned columns, making the output much cleaner and easier to read.
Pro-Tip: To quickly find a specific process and its details, you can pipe the output to grep: ps aux | grep 'your_process_name' | awk '{printf "%-10s %-8s %-5s %-5s %-10s %s\n", $1, $2, $3, $4, $5, $11}'
Linux Tips & Tricks | © ngelinux.com | 4/30/2026
