Syntax

Bash For Loop over a Range Syntax

In Bash, for loop over a range: loops over a number range — for i in {1..10}; do echo "$i" done

Quick Answer

Syntax
for i in {1..10}; do echo "$i" done
BashSyntax

For Loop over a Range

Code example
for i in {1..10}; do echo "$i" done

Loops over a number range.

Learn More

How to for loop over a range in Bash

  1. Open your Bash file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Bash For Loop over a Range Syntax

Use for i in {1..10}; do echo "$i" done.

Related Syntax References

Frequently asked questions

What is the Bash syntax for for loop over a range?

Use this pattern: for i in {1..10}; do echo "$i" done

Can I copy this Bash code example?

Yes. Use Copy code and adapt the example to your program.

Is this Bash syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify