From this site:

for i in $(seq 1 10);
do
    echo $i
done
Answer from Rob Rolnick on Stack Overflow
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › bash for loop syntax and examples
Bash For Loop Examples - nixCraft
January 31, 2025 - It is characterized by a three-parameter loop control expression; consisting of an initializer (EXP1), a loop-test or condition (EXP2), and a counting expression/step (EXP3). for (( EXP1; EXP2; EXP3 )) do command1 command2 command3 done ## The ...
People also ask

How do I loop over command-line arguments?
Use `for arg in "$@"; do` to iterate over all positional parameters passed to the script.
🌐
linuxize.com
linuxize.com › home › bash › bash for loop: syntax and examples
Bash For Loop: Syntax and Examples | Linuxize
How do I loop over lines in a file?
Use a `while` loop with `read` instead: `while IFS= read -r line; do echo "$line"; done < file.txt`. A `for` loop is not suited for line-by-line file reading because it splits on whitespace, not newlines.
🌐
linuxize.com
linuxize.com › home › bash › bash for loop: syntax and examples
Bash For Loop: Syntax and Examples | Linuxize
What is the difference between the standard `for` loop and the C-style `for` loop?
The standard `for` loop iterates over a list of items (strings, array elements, a range). The C-style `for` loop uses arithmetic initialization, condition, and step expressions — it is better suited for counter-based iteration where you control the start, end, and step explicitly.
🌐
linuxize.com
linuxize.com › home › bash › bash for loop: syntax and examples
Bash For Loop: Syntax and Examples | Linuxize
🌐
W3Schools
w3schools.com › bash › bash_loops.php
Bash Loops
For loops allow you to iterate over a list of items or a range of numbers.
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › how to write bash shell loop over set of files
How To Write Bash Shell Loop Over Set of Files - nixCraft
March 19, 2024 - You can loop through all files such as *.c, enter: $ for f in ./*.c; do echo "Processing $f file..."; done ... #!/bin/bash # NOTE : Quote it else use array to avoid problems # FILES="/path/to/*" for f in $FILES do echo "Processing $f file..."
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › bash-scripting-for-loop
Bash Scripting - For Loop - GeeksforGeeks
September 15, 2023 - As said earlier, we need to use the variables inside the for loops to iterate over a range of elements. And thus, the C-styled for loops play a very important role. Let's see how we use them. #!/bin/bash n=7 for (( i=1 ; i<=$n ; i++ )); do echo $i done
Find elsewhere
🌐
Linuxize
linuxize.com › home › bash › bash for loop: syntax and examples
Bash For Loop: Syntax and Examples | Linuxize
March 2, 2026 - How do I loop over command-line arguments? Use for arg in "$@"; do to iterate over all positional parameters passed to the script. The Bash for loop iterates over a list of items or runs for a defined number of iterations using C-style syntax.
🌐
Red Hat
redhat.com › en › blog › bash-scripting-loops
Introduction to Linux Bash programming: 5 `for` loop tips
March 1, 2021 - If you're not, I'll try to break it down in plain English for you. The basic concept is: FOR a given set of items, DO a thing. The given set of items can be a literal set of objects or anything that Bash can extrapolate to a list.
🌐
Saigontechsolutions
saigontechsolutions.com › bash-for-loop
Bash Scripting - For Loop - GeeksforGeeks
April 19, 2023 - We can use range-based for loops. In this type of loop, we can specify the number to start, stop, and increment in each iteration (optional) in the instruction. There are two ways to do this, i.e. mentioning the increment/decrementer value and incrementing by one by default. The syntax looks like this: #!/bin/usr/env bash for n in {1..5}; do echo $n done
Price   $$
Call   0929768789
Address   268/14 Nguyễn Thái Bình, Phường 12, Quận. Tân Bình, Thành phố Hồ Chí Minh, Việt Nam., 700000, Hồ Chí MInh
🌐
UCSB Library
carpentry.library.ucsb.edu › 2021-01-21-SWC-Bash-online › 05-loop
Loops – Intro to Bash Shell
January 21, 2021 - Typing in commands over and over ... the whole loop on one line (using semi-colons to separate the pieces): $ for datafile in NENE*[AB].txt; do echo $datafile stats-$datafile; done · Using the left arrow key, Nelle backs up and changes the command echo to bash goost...
🌐
MakeUseOf
makeuseof.com › home › programming › everything you need to know about bash for loops in linux
Everything You Need to Know About Bash For Loops in Linux
December 2, 2020 - With nothing to iterate through, a for loop operates on whatever command-line arguments were provided to the script when invoked. For example, if you have a script named args.sh containing the following: ... Bash recognizes this case and treats for a do as the equivalent of for a in $@ do where $@ is a special variable representing command-line arguments.
🌐
Medium
medium.com › @codingcampus › bash-for-loop-with-examples-ff1d88b9ad42
Bash For Loop (With Examples). Bash for loop is a bash statement that… | by CodingCampus | Medium
November 23, 2023 - Bash For Loop (With Examples) Bash for loop is a bash statement that allows code to be executed repeatedly. Loops can be used at the command line prompt or within a shell script. Bash for Loop Basic …
🌐
PhoenixNAP
phoenixnap.com › home › kb › devops and development › bash script for loop explained with examples
Bash Script for Loop Explained with Examples | phoenixNAP KB
July 6, 2023 - The output prints each element to the console and exits the loop. Instead of writing a list of individual elements, use the range syntax and indicate the first and last element: #!/bin/bash # For loop with number range for i in {0..5} do echo "Element $i" done
🌐
Hostinger
hostinger.com › home › tutorials › how to use the bash for loop: syntax and examples
What is a bash for loop? Practical examples and syntax
December 22, 2025 - A Bash for loop is a statement that lets you run a set of commands repeatedly for each listed item. Explore its syntax and practical examples.
🌐
TutorialsPoint
tutorialspoint.com › bash-script-for-loop-explained-with-examples
Bash Script for Loop Explained with Examples
April 12, 2023 - A for loop is a control structure that lets you execute a block of code repeatedly for a fixed number of times, or over a list of values. basic syntax of a for loop is as follows ?
🌐
Guvi
ftp.guvi.in › hub › linux-guide-tutorial › bash-for-loop
Introduction to Bash For Loop
Bash for loop is used to repeat commands by iterating over strings, ranges, arrays, or conditions, with support for break and continue.
🌐
TecMint
tecmint.com › home › bash shell › how to use bash for loop with examples in linux
How to Use Bash For Loop in Linux: A Beginner's Tutorial
June 6, 2023 - You can also easily iterate through values defined in an array using a for Loop. In the following example, the for loop iterates through all the values inside the fruits array and prints them to stdout. #!/bin/bash fruits=("blueberry" "peach" "mango" "pineapple" "papaya") for n in ${fruits[@]}; do echo $n done
🌐
Great Learning
mygreatlearning.com › bash › tutorials › bash-for-loop
Bash For Loop - Great Learning
Some of the 'for loop' examples are given below for instance how do they work: ... In the Following we will print each word of a string / sentence in a single line. #!/bin/bash #This is the basic example of 'for loop'. learn="Start learning from Great Learning Academy and Achieve Your goals." for learn in $learn do echo $learn done echo "Thank You."
🌐
Compciv
compciv.org › topics › bash › loops
For and Read-While Loops in Bash
It's hard to tell, but a "loop" did execute. It just executed once. OK, so how do we make it execute more than one time? Add more (space-separated) elements to the right of the in keyword. Let's add four more 1's: user@host:~$ for x in 1 1 1 1 > do > echo Hi > done Hi Hi Hi Hi