win7-64
cygcheck 3.1.7
gawk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)
gawk outputs an error for the program invocation line. The program works in debug mode (gawk -D -f create) but not from inside my cygwin shell. Other gawk programs work fine. Please tell me what I am doing wrong?
> create 2000_RDA.csv
gawk: cmd. line:1: ./create
gawk: cmd. line:1: ^ syntax error
gawk: cmd. line:1: ./create
gawk: cmd. line:1: ^ unterminated regexp
The program
#! /bin/gawk
BEGIN {
outputLine[1] = " const string ";
outputLine[2] = " [] = { "
outputLine[4] = " , "
outputLine[5] = " }\n"
}
BEGINFILE {
line = 1;
name = "y" gensub(/_RDA.csv$/, "", "g", FILENAME);
printf("%s%s%s", outputLine[1], name, outputLine[2]);
}
ENDFILE {
printf("%s", outputLine[5]);
}
{
if (($0 ~ /^[[:digit:]]/)) { # begins with a number
if (line == 1) { printf("\"%s\"\n", $0); line = 0; }
else { printf("%s\"%s\"\n", outputLine[4], $0); }
}
}