BEGIN and END are causing syntax errors in my pretty simple script.
The general outline of the script is:
args=("$0")
gawk -v var=0 '{
*do stuff based on input file
*stuff gets assigned to var
*END{ print var}
}' ${args[0]}
I get the following error, and I have no idea why:
gawk: cmd. line:x: END { ... }
gawk: cmd. line:x: ^ syntax error
EDIT:
So Adam Liss was right! I had an error with my curly braces.
What I was essentially doing was gawk ‘{script END{stuff}}’ when I should’ve been doing gawk'{script}END{stuff}’
Thanks Adam!
This might work for you: