Added pv support for mysqls

This commit is contained in:
斟酌 鵬兄 2018-12-14 05:52:33 +08:00
parent d81aed5899
commit 3846e51f53

View File

@ -30,10 +30,19 @@ function mysqls () {
echo
else
GZIP=false
if [ "$1" == "z" ]; then
PV=false
_ANY=false
if [[ "$1" == *z* ]]; then
GZIP=true
shift
fi
_ANY=true
fi
if [[ "$1" == *p* ]]; then
PV=true
_ANY=true
fi
if $_ANY; then
shift
fi
USER=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $5 }')
PASS=$(grepmysql $1 true)
@ -44,10 +53,17 @@ function mysqls () {
fi
if $GZIP; then
gunzip -c $3 | mysql -u $USER --password=$PASS -D $2
if $PV; then
pv $3 | gunzip | mysql -u $USER --password=$PASS -D $2
else
gunzip -c $3 | mysql -u $USER --password=$PASS -D $2
fi
else
mysql -u $USER --password=$PASS -D $2 < $3
if $PV; then
pv $3 | mysql -u $USER --password=$PASS -D $2
else
mysql -u $USER --password=$PASS -D $2 < $3
fi
fi
fi
}