I am setting a variable as follows and when I print it out I get something unexpected.
sql="values ('$yy-$mm-$dd $time','$tz', $load)"
printf "%s\n" "$sql"
)alues ('2011-01-01 23:55:00','EST', 5081.2
)alues ('2011-01-01 23:55:00','EST', 475.8
)alues ('2011-01-01 23:55:00','EST', 1574.9
Somehow the closing parenthesis is at the beginning of the line?! I check $load to make sure there is no newline character in it.
I am not sure what to try.
loadvariable is probably coming from a source that uses DOS/Windows line endings (which have a carriage return in addition to the linefeed that unix programs expect. See "Are shell scripts sensitive to encoding and line endings?" Note that both carriage return and linefeed are nonprinting characters, so checking a variable for them is nontrivial.