I have a bash script but at a certain point I need to run a lot of queries, like the database name and table prefix are variables.
I have it like this:
mysql -u root -e "INSERT INTO $1.$6TABLA ... ... ..;"
It works fine but the script is already huge like 2000 lines and I do a lot of closures and sql calls.
Therefore, I want to put all the queries in a .sql file. It works, but the variables $1.$6 are lost.
mysql -u root -p $1< /var/www/consultas.sql
and he answers me:
ERROR 1146 (42S02) at line 2: Table '$1.$6....' doesn't exist
Since the variables are not interpreted within the sql file, how can I correct either passing the variables to the .sql or doing a replace
in the file