Our Knowledge Base provides step-by-step guides, troubleshooting tips, and expert insights to help you manage VPS, dedicated servers, domains, DDoS protection, and more — all designed to make your experience with us fast, secure, and stress-free.
In this article, we will cover the basics of the sequence expression in Bash.
The Bash sequence expression generates a range of integers or characters by defining a start and the end point of the range. It is generally used in combination with for loops.
The sequence expression takes the following form:
Here’s the expression in action:
When no INCREMENT is provided the default increment is 1:
You can also use other characters. The example below prints the alphabet:
If the START value is greater than END then the expression will create a range that decrements:
When an INCREMENT is given, it is used as the step between each generated item:
Each generated number is greater than the preceding number by 5:
When using integers to generate a range, you can add a leading 0 to force each number to have the same length. To pad generated integers with leading zeros prefix either START and END with a zero:
The expression can be prefixed or suffixed with other characters:
If the expression is not constructed correctly, it is left unchanged:
The Bash sequence expression allows you to generate a range of integers or characters.