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,8 +30,17 @@ function mysqls () {
echo echo
else else
GZIP=false GZIP=false
if [ "$1" == "z" ]; then PV=false
_ANY=false
if [[ "$1" == *z* ]]; then
GZIP=true GZIP=true
_ANY=true
fi
if [[ "$1" == *p* ]]; then
PV=true
_ANY=true
fi
if $_ANY; then
shift shift
fi fi
@ -44,10 +53,17 @@ function mysqls () {
fi fi
if $GZIP; then if $GZIP; then
if $PV; then
pv $3 | gunzip | mysql -u $USER --password=$PASS -D $2
else
gunzip -c $3 | mysql -u $USER --password=$PASS -D $2 gunzip -c $3 | mysql -u $USER --password=$PASS -D $2
fi
else
if $PV; then
pv $3 | mysql -u $USER --password=$PASS -D $2
else else
mysql -u $USER --password=$PASS -D $2 < $3 mysql -u $USER --password=$PASS -D $2 < $3
fi fi
fi
fi fi
} }