How to print filename with awk on Linux / Unix

Originally published at: https://www.cyberciti.biz/faq/how-to-print-filename-with-awk-on-linux-unix/

I would like to print filename with awk on Linux / Unix-like system. How do I print filename in BEGIN section of awk? Can I print the name of the current input file using gawk/awk?


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki