写下常用脚本,利用EOF子命令来执行后续命令,没事练练手
#!/bin/bash #author merci echo "Please input old password" read o echo "Please inpput new password" read n echo "Please inpput repassword" read r if [ $n != $r ]; then echo "Password Inconsistent !" exit 1 fi mysql -u root -p$o <<EOF use mysql; update user set password=password("$n") where user="root"; flush privileges; exit EOF
分解符EOF可以定义任何字符串,这个和php的定界符还是有一丢丢相似