bash外壳嵌套循环 [英] bash shell nested for loop
本文介绍了bash外壳嵌套循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编写一个嵌套的for循环,该循环必须在bash shell提示符下工作.嵌套在单行命令中的for循环中.
I want to write a nested for loop that has to work in the bash shell prompt. nested for loop in Single line command.
例如
for i in a b; do echo $i; done
a
b
在上面的示例中,for循环在单行命令右执行. 像这样,我在shell提示中尝试了嵌套的for循环.它不起作用. 这该怎么做.请对此进行更新.
In the above example, for loop is executed in a single line command right. Like this I have tried the nested for loop in the shell prompt. Its not working. How to do this. Please update me on this.
推荐答案
这不是一个嵌套循环,而仅仅是一个循环.嵌套版本也适用:
This is not a nested loop, just a single loop. And the nested version works, too:
# for i in a b; do for j in a b; do echo $j; done; done
a
b
a
b
这篇关于bash外壳嵌套循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文