首页 > 代码库 > case while
case while
#!/bin/bash
#create by howhy 20161214
#mysql server start stop restart
. /etc/init.d/functions
mysqldir="/opt/local/mysql"
[ -e "$mysqldir" ] && cd "$mysqldir"
usage(){
echo "$0 {start|stop|restart}"
exit 2
}
start(){
[ -f $mysqldir/mysqld.pid ] && {
echo "mysql server is running..."
exit 2
}
./bin/mysqld_safe &>/dev/null &
[ $? -eq 0 ] && action "mysql server start..." /bin/true
}
stop(){
[ ! -f $mysqldir/mysqld.pid ] && {
echo "mysql server has stopped..."
exit 2
}
./bin/mysqladmin -uroot -pwoshishui shutdown &>/dev/null
[ $? -eq 0 ] && action "mysql server stop..." /bin/true
}
[ $# -ne 1 ]&&{
usage
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
usage
esac
#!/bin/bash
a=1
sum=0
while [ $a -le 100 ]
do
#let sum=sum+a
#let a=a+1
((sum+=a))
((a++))
done
echo $sum
while 读取文件
while read line
do
echo $line
done </opt/file.txt
case while