I'm trying to make a script to backup my database.
But I wanted to not need to provide the bases name when I run the script, but save each base in a different file.
My script looks like this:
#!/bin/bash
BASES= mysql -u *** -p"***" -B -N -e "SHOW DATABASES"
IFS='\n ' read -r -a array <<< "$BASES"
echo $BASES
echo $IFS
In the first line I'm listing the bases and saving in the variable BASES
.
The second line, I tried to break the variable in an array separating by the line break but it did not work.
The output of BASES
looks like this:
base1
base2
base3
.
.
.
How to turn this output into an array?