我有一个脚本,我想从第二个列表中指定的数组中删除项目,我有以下代码,但它不起作用:
db_exclude=( 'information_schema' 'mysql' )
databases=$(/usr/bin/mysql --defaults-extra-file=/etc/unimicrosys/sqlbackup/my.cnf -e 'show databases' -s --skip-column-names)
length=${#databases[@]}
for exclude in $db_exclude[@]; do
for (( i=0; i<$length; i++ )); do
echo $i
if [[ databases[$i] = $exclude ]]; then
unset $databases[$i];
fi;
done
done