The script below is loading in a bunch of csv files into a mysql db. I am trying to execute this function within the loop but the mysql table field called return is causing the script to think it should execute the function return.
The ` around return is to escape it for mysql, its a mysql keyword.
for f in *.txt;
do
mysql -uroot -ppassword -e "LOAD DATA INFILE '$f' INTO TABLE info FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (`return`,`id`,`field1`,`field2`);";
done
it’s the stupid quoting convention in mysql of using backtick characters. Can you use Single-quotes instead, ie
', ie'return'?Backticks mean “perform command substitution in this current command in the shell”, so it is trying to run the command
return.If you can’t use
'return'then you can escape ALL of the backticks, likeIHTH