|
- #!/bin/sh
- # this is a example for break and continue.
- for x in a b c d e f g h i
- do
- for y in 1 2 3 4 5 6 7 8 9
- do
- echo "current job is $x$y "
- echo " input 'n' to do next job "
- echo " 's' to skip other jobs in current level "
- echo " 'x' to terminate all jobs "
- read action
- if [ $action = n ]
- then
- echo " do next job "
- continue
- elif [ $action = s ]
- then
- echo " skip ther other jobs in crrent level "
- continue 2
- elif [ $action = x ]
- then
- echo "terminate all jobs "
- break 2
- fi
- done
- done
- #end
复制代码
这个是关于工业流程用到continue和break经典代码,哪个兄弟能把执行原理一步一步在后面执行的原理啊!
还有就是我到现在还是搞不懂,循环嵌套,遇到比如:
while ~~~~~~
do
while ~~~~~
do
done
done
和
for ~~~~~~
do
for ~~~~~~
do
done
done
和
if ~~~~~~
then
if ~~~~~~
then
fi
fi
之类的嵌套语句就傻了,不知道他们是先执行里面的层还是外面的层,或者是不管里层,外层,根据条件执行,有哪位恳给我们这些菜鸟们多举点例子说明一下啊!
因为这些都是一些非常基础的经典问题!谢谢个位兄弟! |
|