<p>How do I iterate over a range of numbers in Bash when the range is given by a variable?</p>

<p>I know I can do this (called "sequence expression" in the Bash <a href="http://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion" rel="noreferrer">documentation</a>):</p>

<pre><code> for i in {1..5}; do echo $i; done
</code></pre>

<p>Which gives:</p>

<blockquote>
  <p>1 <br/>
  2 <br/>
  3 <br/>
  4 <br/>
  5</p>
</blockquote>

<p>Yet, how can I replace either of the range endpoints with a variable? This doesn't work:</p>

<pre><code>END=5
for i in {1..$END}; do echo $i; done
</code></pre>

<p>Which prints:</p>

<blockquote>
  <p>{1..5}</p>
</blockquote>

You can use
```
```
for i in $(seq $END); do echo $i; done
```
```