shell脚本中的循环
在新一点的shell中,可以使用下面两种写法来写循环。
SERVICE_NAME=(api ess collect registry ras-cluster) loop() { echo "Clean RCS service." for service in "${SERVICE_NAME[@]}" do echo $service done } loop echo "######" echo ${SERVICE_NAME[1]} echo "${SERVICE_NAME[@]}" SERVICE="api ess collect registry ras-cluster" for i in $SERVICE; do echo $i/bin done
老一点的shell中需要这样写。
for i in `seq 1 5`;do echo $i;done