I have the following code that works perfectly in Cygwin
$ awk -F, '
BEGIN {months ["JAN"]="AP01"; months ["FEB"]="AP02"; months ["MAR"]="AP03";
months ["APR"]="AP04"; months ["MAY"]="AP05"; months ["JUN"]="AP06";
months ["JUL"]="AP07"; months ["AUG"]="AP08"; months ["SEP"]="AP09";
months ["OCT"]="AP10"; months ["NOV"]="AP11"; months ["DEC"]="AP12";
}
{TMP = FILENAME
sub (/\..*$/, "", TMP)
print> "a_" TMP "_ACTUAL_"months[substr($3,0,3)]"-20" substr($3,5,2)"_RR.txt"
}
' *.txt
This codes splits any txt file into multiple txt files based on field number three. The new files are named using a portion of the original file and the Accounting Periods (AP) listed at the beginning of the script.
As I move the script to the server (Solaris) it generates a syntax error during execution. The error reads: Syntax error near line 7. Line 7 is the assignment of the current filename to the TMP variable.
As I mentioned this is not an issue in Cygwin. The script runs as expected but not so in Solaris. Any help will be greatly appreciated