title: For loop in Unix
body: <p>I am new to Unix programming and I am not able to figure out what is wrong with this code:</p>
  
  <pre><code>#!/bin/sh
      i=1
      max=10
          for i in {1..$max}
          do
              echo $i;
          done
  </code></pre>
  
  <p>If I try the above code as follows it works:</p>
  
  <pre><code>#!/bin/sh
      i=1
      max=10
          for i in {1..10}
          do
              echo $i;
          done
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>#!/bin/sh
      i=1
      max=10
          for i in {1..`echo $max`}
          do
              echo $i;
          done
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#!/bin/sh
      i=1
      max=10
          for i in {1..`expr $max`}
          do
              echo $i;
          done
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#!/bin/sh
      i=1
      max=10
          for i in {1..`echo $max | bc`}
          do
              echo $i;
          done
  </code></pre>
  
  <p>But it is also not working.. Can anyone tell me how come it will work..?</p>