In the following script, I try to get all tables name from a mysql database and I expect all table's name printed out, but no matter what I do or which method I use, it just doesn't work. the printed string I suppose are tables name overlapped on each other:
watchdoglescabularyrchygsey
What's wrong with this script?
mysql -Nse 'show tables' DATABASE |
{
while read table
do
alltables="$alltables $table"
done
echo $alltables;
}
mysql -Nse 'show tables' DATABASE | xargsmysqlcommand by itself? That said, always useIFS= read -r tableunless you have a compelling reason not to. You might also want to check the output ofecho "$alltables" | odto get a better idea of exactly what characters are in the value.