I'm trying to write a shell script that dumps all tables with a user specified table prefix. The following is part of the script:
variable=vardata
mysql -u user -p -N information_schema -e "SELECT table_name FROM tables WHERE table_schema = 'dbname' AND table_name LIKE 'test_$variable%'"
Accessing the variable can't work like this, because of the hard quotes in the SQL statement, but how else can I do it? I tried MySQL variables @var, but that also doesn't seem to work with the LIKE operator.