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 example,
for i in a b; do echo $i; done
a
b
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.
One one line (semi-colons necessary):
Formatted for legibility (no semi-colons needed):
There are different views on how the shell code should be laid out over multiple lines; that's about what I normally use, unless I put the next operation on the same line as the
do
(saving two lines here).This is not a nested loop, just a single loop. And the nested version works, too: