Skip to content

Instantly share code, notes, and snippets.

@ericksuryadinata
Created October 11, 2018 14:02
Show Gist options
  • Save ericksuryadinata/94acdfcd6b840ad206aa79c1e2a42156 to your computer and use it in GitHub Desktop.
Save ericksuryadinata/94acdfcd6b840ad206aa79c1e2a42156 to your computer and use it in GitHub Desktop.
#!/bin/sh
exit=1
getout=0
if [ "$1" = "" ];
then
echo "You must suply filename to import"
getout=1
else
file=$1
fi
if [ "$2" = "" ];
then
echo "You must suply username of your mysql"
getout=1
fi
if [ "$3" = "" ];
then
echo "You must suply your destination database"
getout=1
fi
if [ "$getout" -eq "$exit" ]
then
echo "usage = pv FILENAME | mysql -u USERNAME -p DATABASE"
exit
else
if [ "${file##*.}" = "sql" ]
then
pv $1 | mysql -u $2 -p $3
else
echo "You must specified sql file"
echo "${file##*.}"
exit
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment