while循环与until循环的区别

 

001、while循环:条件满足一直执行

[root@pc1 test1]# i=1     ## 条件满足,一直执行
[root@pc1 test1]# while [[ $i -le 3 ]]; do echo $i; i=$((i+1)); done
1
2
3

 

002、until循环;条件不满足一直执行

[root@pc1 test1]# i=1        ## 条件不满足,一直执行,与while循环相反
[root@pc1 test1]# until [[ $i -gt 3 ]]; do echo $i; i=$((i+1)); done
1
2
3

。 

 

posted @ 2024-02-19 12:05  小鲨鱼2018  阅读(27)  评论(0编辑  收藏  举报