Skip to content

Instantly share code, notes, and snippets.

@lifuzu
Created January 10, 2014 06:12
Show Gist options
  • Save lifuzu/8347690 to your computer and use it in GitHub Desktop.
Save lifuzu/8347690 to your computer and use it in GitHub Desktop.
bash to list mysql database, set them to array
while read dbname; do dbarray+=("$dbname"); done < <(mysql -u username -ppassword -e 'show databases;' -B | grep reviewdb)
echo ${dbarray[*]}
for dbname in `echo ${dbarray[*]}`; do echo $dbname; done
@jirikmik
Copy link

jirikmik commented Apr 3, 2018

Thank You very much!
Better to add -N parameter for mysql command
J.M.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment