I have an awk script that I run against a couple of files. I call it this way:
awk -f script.awk file1 file2
script.awk looks something like this:
BEGIN {FS=":"} { if( NR == 1 ) { var=$2 FS=" " } else print var,"|",$0 }
The first line of each file is separated by colons. for every other line, I want it to return to the default file separator by default.
this works fine for the first file, but fails because FS not reset before : after each file, because the BEGIN block is processed only once.
TL; DR: is there a way to get awk to process a BEGIN block once for each file it transfers?
I run this on cygwin bash, if that matters.
source share