To get you pointed into the right direction you are going to need the command "mysql -e" to build the script from. As an example, I have system monitoring scripts where I need MySQL information from bash so it can be mixed with other commands to pull system information.
Tiny Example
Code:
echo "What is the MySQL root password?";\
read MYSQLPASS;\
iostat ;\
mysql -uroot -p$MYSQLPASS -e 'SHOW PROCESSLIST;' ;\
ipcs -c
So in theory you should be able to output the information to bash for further processing.
Code:
echo "What is the MySQL root password?";\
read MYSQLPASS;\
for i in $(mysql -uroot -p$MYSQLPASS -e 'SELECT * FROM database_name.table_name.row_name;) ;\
do touch $i ;\
done