美文网首页
第一节 for循环使用(shell)

第一节 for循环使用(shell)

作者: 萝莉薇 | 来源:发表于2020-01-11 19:20 被阅读0次

1.for死循环

#!/bin/bash

count=0
for ((;;))
do
  if [ $count -ge 10 ]
  then
    break
  fi
  count=`expr $count + 1`
  sleep 1s
  echo "当前$count"
done
echo "执行完成"

PS:执行10次后退出

2.for循环100次

#!/bin/bash

for loop in {1..100}
do
    echo "The value is: $loop"
done

相关文章

网友评论

      本文标题:第一节 for循环使用(shell)

      本文链接:https://www.haomeiwen.com/subject/tijbactx.html