jonseager jonseager - 2 years ago 118
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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download