Call a awk script with variable and input filename

HI,

MY question is a very simple one:

if i want to call an awk script with the input file name and also pass a variable value , then how to do it.

#>awk -f my_script.awk -v variable=value my_inputfile.txt

I can't do it like this.
throws error:
awk: my_script.awk:18: (FILENAME=y_inputfile.txt FNR=1) fatal: attempt to access field -2147483648

Any idea how to do it then?

---------- Post updated at 02:55 AM ---------- Previous update was at 02:46 AM ----------

OK, guys, my script was having some problem it seems, sorry for troubling anyone, if anyone had started to analyse it.

the command format is ok

1 Like