I have a variable in a script with the list of folder names with dash in their names
DBDIR="some directory"
dbdash=`ls -l $DBDIR | egrep '^d' | grep '.-.' | awk '{print $9}'`
And I want to drop every database with the same names with the folders in the variable "dbdash"
dbhype=($dbdash)
for dbtry in ${!dbhype[*]}
do
mysqladmin -u$dbUser -p$dbPass 'drop database if exists `'${dbhype[$dbtry]}'` CHARACTER SET utf8 COLLATE utf8_general_ci;'
done
But this error came out after running the script
mysqladmin: Unknown command: 'drop database if exists
folder_nameCHARACTER SET utf8 COLLAT'
How can I delete these databases using script? Please help.
ls, and don't try to store a list of files in a flat string.cd "$DBDIR"; dbhype=( *-*/ )