case while for

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

for a in {1..10};do echo $a ;done

for((a=1;a<=100;a++));do let sum=sum+a ;done

 

转载于:https://www.cnblogs.com/howhy/p/6180331.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值