First I want to thank Kph for reminding me of the xargs command, I didn't test his solution, but I think it would have of worked.
David the H.
I'm sorry for the not using the code markup and to answer your question the basis for the script is to loop through and array containing table names and is supposed to export data from an isolated server to another server.
The expanded command should look like the following with outfilename the generated filename cat'd to the array index value and store23data once of the values in the array that denotes the table name.
Code:
mysql -u root --password="mypass" mydb -e "select * INTO OUTFILE outfilename FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' from store23data";
The above will still fail even though all the variables are expanded, see solution below as to why.
There is an array defined that stores all of the table names
The "outfilename" is generated by using the date utility with parameters for month/day/year/hour/min/sec and the table name direived from the array index as shown below.
Code:
"`date '+%m%d%y%H%M%S'`${surveys[$a]}"
The solution to my issue didn't have anything to do with escape sequences, well maybe it did a little, but when using mysql and an outfile query I had to quote the outfile name parameter within the query and wasn't in my original attempt.
The solution is very similar to my original line to query the database putting the results into a file, the difference is the quoted '$outfilename' variable in the command.
Code:
mysql -u root --password="mypass" mydb -e "select * INTO OUTFILE '$outfilename' FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' from ${surveys[$a]}";
Thanks again,
Carl M.