Created
September 10, 2013 03:27
-
-
Save onigra/6504611 to your computer and use it in GitHub Desktop.
テンプレ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_DRYRUN="" | |
OPTIND_OLD=$OPTIND | |
OPTIND=1 | |
while getopts "n" opts | |
do | |
case $opts in | |
n) _DRYRUN="TRUE" ;; | |
esac | |
done | |
_SCRIPT_PATH=`echo $(cd $(dirname $0); pwd)` | |
_SQL_FILES=(`ls -dF ${_SCRIPT_PATH}/sql/*`) | |
if [ "$_DRYRUN" = "TRUE" ]; then | |
for (( i = 0; i < ${#_SQL_FILES[@]}; i++ )) | |
do | |
echo "mysql -u user -p[password] < ${_SQL_FILES[$i]}" | |
done | |
else | |
for (( i = 0; i < ${#_SQL_FILES[@]}; i++ )) | |
do | |
mysql -u user -ppassword < ${_SQL_FILES[$i]} | |
done | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment