home Computers Awk – Error – Unterminated String

Awk – Error – Unterminated String

I was frustrated using awk recently. I had created a awk file to do some batch processing of text file information. Anyhow, I had a large text section to create an SQL statement from. It spanned multiple lines and I had used a backslash “\” to indicate the string continued on the next line.

I had a syntax problem however. It was saying I had an unterminated string. I googled for the answer and checked to make sure every line of my text section had a backslash (which it did) and I couldn’t figure it out.

Below is the error I had.

awk: query.awk:2: print "SELECT \
awk: query.awk:2:       ^ unterminated string

Anyhow, last straw was to go to everyline that had the backslash at the end and remove any spaces at that came after the backslash (so between the slash and the true end of the line). This fixed my problem.

Leave a Reply