I'm writing a bash script to clean wordpress based websites easily. I've a MySQL query to run with respect to a bash variable which I'm unable to figure out.
Since most of wordpress security plugins change database's table prefix so I want to use:
db_prefix=$(cat wp-config.php | grep "\$table_prefix" | cut -d \' -f 2)
to know of the exact table prefix which is in use & then use this MySQL query:
mysql -D${db_name} -u${db_user} -p${db_pass} << "EOF"
SELECT *
FROM `wp_options`
WHERE `option_name` LIKE 'template';
EOF
Now I want to use $db_prefix as variable on 3rd line of MySQL query by replacing wp_ with $db_prefix.
Is there any way to do so?
EDIT: I didn't know that it's that active, I really appreciate all of contributers, you'll see me contributing here too.
Bash script is live here now: https://github.com/saadismail/wp-clean
Thanks to all of you guys & girls...