I have a text file that has information for several locations. Each new section in the file has a header. I am trying to take all the information under a single header, strip out the header, and move it to a separate file. All sections move to a separate file based on header information. I am programming this in a shell script using ksh running on aix.
awk '/FILE-HDRPQ/{x=substr ($0,11,6)}NR>1{print $0 > $TRANSDIR"/"x"_prchgrpt.txt";}' $TRANSDIR/$prcfile
FILE-HDRPQ is the first part of the header. $0 contains all columns from that header until the line before the next header. x=an identifying number in the header which is used to create the filename that $0 (minus the top header line) will dump into.
Variables $TRANSDIR and $prcfile help us name the file and place it in the proper directory. These variables are called out earlier in the script.
I am now getting
awk: 0602-562 Field $() is not correct.
when I run the script. Can't for the life of me figure out what is wrong. I have tried playing with single and double quotes.