for i in {1..10} ; do ... ; done
years=(2018 2019)
days=(74 274)
for year in "${years[@]}"; do
for day in $(seq -w ${days[0]} ${days[1]}); do
echo $year
echo $day
done
done
for ((i = 1; i <= 10 ; i++)); do
echo $i
done
#!bin/bash
for i in {1..5}
do
echo i:$i
done
for VARIABLE in 1 2 3 4 5 .. N
do
command1
command2
commandN
done
for VARIABLE in file1 file2 file3
do
command1 on $VARIABLE
command2
commandN
done
Use for in bash for iterating words in a string or values in an array as:
for value in {1, 2, 3}; do echo $value; done
for value in $(cat arguments_files.txt); do [some_command]; done
And use while for iterating lines from a pipe output as:
cat arguments_file.txt | while read line; do [some_command]; done
for FILE in $(ls -A); do la $FILE; done
for var in value1 value2 value3
do
command1 on $var
command2
commandN
done
for <item> in <list of items>
do
<command to run>
done
#!/bin/bash
for i in {1..5}
do
echo "Welcome $i times"
done