Answered by : steamboatid
{"tags":[{"tag":"textarea","content":"#!\/bin\/bash\nfor i in {1..5}\ndo\n echo \"Welcome $i times\"\ndone","code_language":"whatever"}]}
Source : https://www.cyberciti.biz/faq/bash-for-loop/ | Last Update : Mon, 06 Mar 23
Answered by : andrei-srhxj5d9r55l
#!/bin/bash
# A simple bash "for loop" example below...
# This loop will run 4 times, and will echo the number in sequence as it goes.
# 3 is increment size
# Mind the double . between the {}
# Note how the variable is called with the $ prefix, which can be done within the "" quotes!
for i in {1..12..3}
do echo "This is loop number $i"
done
# Result :
# This is loop number 1
# This is loop number 4
# This is loop number 7
# This is loop number 10
Source : | Last Update : Thu, 28 Jul 22
Answered by : big-breasted-blueeyed-baby-badgers-beating-band
for ((i = 1; i <= 10 ; i++)); do echo $i
done
Source : | Last Update : Mon, 18 Apr 22
Answered by : adrien-wehrl
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
Source : | Last Update : Mon, 20 Apr 20
Answered by : calm-cockroach-78xa3unw3335
for i in {1..10} ; do ... ; done
Source : https://stackoverflow.com/questions/49110/how-do-i-write-a-for-loop-in-bash | Last Update : Wed, 30 Mar 22
Answered by : agenttequila
#!bin/bash
for i in {1..5}
do echo i:$i
done
Source : https://hakin9.org/bash-introduction-for-hackers-part-2/ | Last Update : Thu, 02 Jun 22
Answered by : famous-fowl-cpxmadu0ymm1
for VARIABLE in file1 file2 file3
do command1 on $VARIABLE command2 commandN
done
Source : https://www.cyberciti.biz/faq/bash-for-loop/ | Last Update : Thu, 09 Jul 20
Answered by : armando-flores
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
Source : | Last Update : Mon, 02 Nov 20
Answered by : you
#!/bin/bash
for i in {1..5};
do echo $i
done
Source : | Last Update : Tue, 19 Sep 23
Answered by : chilled
while [ <some test> ]
do
<commands>
done
Source : https://ryanstutorials.net/bash-scripting-tutorial/bash-loops.php | Last Update : Sun, 15 Mar 20