jonseager jonseager - 1 year ago 76
Bash Question

GAWK Script - Print filename in BEGIN section

I am writing a gawk script that begins

#!/bin/gawk -f

I am calling the file via
./script file1.html
but the script just returns nothing. Any ideas?

Answer Source

you can use ARGV[1] instead of FILENAME if you really want to use it in BEGIN block

awk 'BEGIN{print ARGV[1]}' file