title: Assign command line argument to variable in shell script
body: <pre><code>#!/bin/sh
  
  a=0
  
  while [ $a -lt $# ]
  do
     var_no=$a
      echo "var_no value is $var_no"
      dir_no=`expr $a + 1`
      dirname=$dir_no
      echo "dirname value is $dirname" # $n is the command line arg   
      if [ -d $dirname ]
          then
          echo " $dirname exists"
          else
          echo "[$dirname]  not exist"
          mkdir $dirname;
      fi
     a=`expr $a + 1`
  done
  </code></pre>
  
  <p>when i am try to assign from arguments to a shell variable it's not showing the expected output as shown below.</p>
  
  <p>Output is </p>
  
  <pre><code>$sh while.sh xyz yzx
  var_no value is 0
  dirname value is 1 ------ but expecting xyz
  This dirname 1 exists 
  var_no value is 1 
  dirname value is 2 ------ but expecting yzx
  This dirname 2 exists
  </code></pre>