construct allows to repeat for a given number of times a code block code1
. The number of the current cycle is saved in current_cycle
. After in
you can write which numbers the variable current_cycle
must assume. The structure is:
for current_cycle in 1 2 3 4 5; do
For example, to cycle 5 times, you can write:
# This script executes 5 cycles in which the variable
# current_variable takes the values 1, 2, 3, 5, 10
for current_variable in 1 2 3 5 10; do
echo "Current cycle: $current_variable"
A special element is the asterisk (*). It allows to execute for
as many times as the number of files contained in the current folder.
No comment present!
Write a comment
You can write here a comment to the article you've just read. Smiles, links and images are not allowed. The maximum comment length is 4000 characters. Please be polite, all the offensive messages will be deleted.