2

Generate a sequence of numbers using Brace Expansion

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

October 25, 2019diego

Explanation

In Bash, {1..3} is expanded to the numbers 1 2 3. You can read more about it in man bash, search for "Brace Expansion".

By using an expression like this in a for loop, we can do something for each number in the range. In this example we simply print the number using echo.

Limitations

This is Bash specific, it may not work with simply /bin/sh.

Related one-liners

3

Generate a sequence of numbers using a simple for loop

for ((i=1; i<=10; ++i)); do echo $i; done

November 4, 2014bashoneliners

Alternative one-liners