Learn powerful awk tricks in Linux to analyze text like a pro!
This short covers line counting, column filtering, and conditional printing with examples.
📁 Commands used:
awk 'END { print NR }' file.txt
Command 2: Print line number followed by the first column
awk '{print NR "- " $1 }' file.txt
Command 3: Match lines with field count less than zero (always false, but now prints line numbers)
awk 'NF less than 0 {print NR}' file.txt
Command 4: Print lines where the second column is '50'
awk '{ if ($2 == "50") print $0 }' file.txt
Use these in your bash terminal to parse data files effectively.
🔹 Command 3 is a logic trick — it will never return results but shows how conditions work.
🔹 Command 4 scans for lines where the second column equals 50.
#linux #awk #linuxcommands #devopstips #bashscript #terminalcommands #linuxshorts #devopseazy #cli