Text Processing (Grep/Sed/Awk)
Precise Column Extraction with AWK Field Selection
🧩 The Challenge
You need to extract specific columns from a whitespace-separated log file or command output without knowing the exact character indices.
💡 The Fix
Use the AWK print function to isolate individual fields based on their numerical order in each line.
ps aux | awk '{print $2, $11}'
⚙️ Why It Works
By default, AWK treats any sequence of whitespace as a field delimiter and assigns each segment a numeric variable starting from $1.
🚀 Pro-Tip: Use the -F flag to specify a custom delimiter if your data uses commas or colons instead of spaces.
Linux Tips & Tricks | © ngelinux.com | 7/11/2026
