Consider the following awk statement which sums the values of column 1 in a file
cat $1 e | awk ' {total=total+$1} # this comment does not contain any single quote marks
END {printf("%.2f\n",total)}
'
It works as expected.
Now let's keep the same statement, but change the comment to have a single quote mark inside
cat $1 e | awk ' {total=total+$1} # don't do this
END {printf("%.2f\n",total)}
'
When I run this in either Mac Os or Centos, I get the following error
./bad_sum: line 2: syntax error near unexpected token `
./bad_sum: line 2: ` END {printf("%.2f\n",total)}'
It looks like awk is trying to match the quote mark in don't with the quote mark after awk and thus gets confused. But since comments are supposed to be ignored, how can this be explained?