bash: for loop
-
Take into account the main readme for this section. README first.
Normally done with a shell script but for demonstration purposes the command line is used.
Syntax until: for name [ [in [words …] ] ; ] do commands; done
What does it do? Execute commands for each member in a list.Using a word list.
$ for fruit in apples oranges pears; do echo "I like $fruit"; done I like apples I like oranges I like pears
Using an expression.
$ count=10 $ for ((i = 0 ; i < count ; i++ )); do echo "$i"; done 0 1 2 3 4 5 6 7 8 9
© Lightnetics 2024