In this article, we will see how to use FOR loops in an easy FOR loop example in bash.
FOR loops work similar to FOR loops in other programming languages. It executes statement or statements of code with iteration.
Lets look to its syntax.
for i in $var;
do
echo $i
done
Lets see it in bash shell scripting example.
As above output indicates, we created a variable and a FOR loop. Variable starts with initial value as string . Each cycle, it iterates one word within string sentence and echo it to terminal.