Shell script function under mysql loop
I am trying to get working a function under mysql loop but could not work. please help me
Code:
#!/bin/bash Thanks you |
Might need a little more information, such as, exactly what is not working?
|
Welcome to LinuxQuestions.
I am not a mysql user and therefore will make a few assumptions. myvariable is a string not an array. I expect ${myvariable[0]} to be the entire string and ${myvariable[1]} to be blank. What does mysql use as a field separator in silent mode (-s) ie. a comma (,)? I assumed there could be more then one row from your query so used tr to replace new lines with a "," which would allow you to split them into and array and iterate them as desired. Code:
test=$( echo $myvariable | tr "\n " "," ) |
in the second mysql call you can leave out -D, every string beside options is automatically interpreted as a database name.
Or try lower case -d . |
All times are GMT -5. The time now is 05:43 PM. |