码迷,mamicode.com
首页 > 其他好文 > 详细

case while

时间:2016-12-14 18:21:12      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:dev   读取文件   action   stop   nbsp   read   file   mysqld   rest   

#!/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

标签:dev   读取文件   action   stop   nbsp   read   file   mysqld   rest   

原文地址:http://www.cnblogs.com/howhy/p/6180331.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!