For me, the most beautiful representation of a loop is like this:
for((x=1;x<=5;x++))
do if [[ -v x ]]
then echo $x
fi
done for((x=1;x<=5;x++))
do if [[ -v x ]]
then echo $x
fi
donePersonally, I never use naked loops if I can avoid them. Either foreach or higher order functions if the language has them.
Aside: [[ -v x ]] tests if the variable x is set. It should probably be [[ x -ne 0 ]] to match the example from the parent.
In sh ? In bash ? In zsh ? I am very glad if it is so in any of them
for i in 1 2 3 4 5; { echo $i; }
for ((i=1;i<=5;i++)) { echo $i; }
(It doesn't work with `while` loops, at least not in bash.)while (ls) { echo Hello; echo World }
does work in zsh
But if your break a line after {, then you get while> prompt and } does not trigger execution
seq 5 | xargs -n1 <...>