Update the USE Lines in an SQL Dump
Added by astuffedtiger on May 16, 2017 17:28
SQLWRITE=0;while read line; do if `echo $line | grep "^USE" 1>/dev/null 2>&1`;then DBNAME=`echo $line  | sed -e 's/\`//g' -e 's/\;//g'|awk '{print $2}'`; if [ $DBNAME = "mysql" ] || [ $DBNAME = "information_schema" ]; then SQLWRITE=0;else SQLWRITE=1; echo $DBNAME;fi; if [ $SQLWRITE = 1 ];then NEWDBNAME="nekohayo_${DBNAME}";TMPLINE="USE \`$NEWDBNAME\`;"; NEWLINE=$TMPLINE; fi;else NEWLINE=$line;fi;if [ $SQLWRITE = 1 ]; then echo $NEWLINE;fi;done <./old\ database.sql;

Comments