Stop getting lost in column hell with awk

Text Processing (Grep/Sed/Awk)

Stop getting lost in column hell with awk

🧩 The Challenge

Dealing with output where the columns shift around because of varying filename lengths or weird process states drives me nuts. I’ve spent way too long trying to guess if I want print $7 or $8.

💡 The Fix

Use awk to just grab the last column regardless of where it starts, which saves you from counting spaces like a caveman.

ps aux | awk '{print $NF}'

⚙️ Why It Works

The NF variable is a built-in that keeps track of the number of fields in the current record, so referencing it directly always points to that final chunk of data.

🚀 Pro-Tip: If you need the last two, use print $(NF-1), $NF to keep your sanity.

Linux Tips & Tricks | © ngelinux.com | 10/7/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted