bash控制语句

for

for iterm in `pwd`; do ls ${iterm};done
for((i=1;i<10;i++));do echo $i;done

while

i=0
while [ $i -le 10 ];
do
	echo $i
	((i++))
done

until

i=0
until [ $i -eq 10 ]
do 
  echo $i
  ((i++))
done

case

#!/bin/bash
apache () {
    echo $(date +%w)
}
nginx () {
 echo $(date)
}
tomcat () {
 echo $(date +%F)
}

case $1 in
 apache|APACHE) echo "starting install apache";apache ;;
 nginx) nginx;;
 tomcat) tomcat;;
 *) Usage:"please input a param" ;;
esac

exit

posted @ 2021-12-21 14:30  mingtian是吧  阅读(31)  评论(0编辑  收藏  举报