title: Loop over the arguments array, without knowing how many arguments, in a shell script?
body: <p>I want to pass many arguments to a shell script which I don't know how many arguments they are going to be and I want to handle them. I did the following code:</p>
  
  <pre><code>int=$1
  src=$2
  
  r=$3
  string=$4
  
  duration=$5
  
  ./start.sh $int $r $src "$string"
  sleep $duration
  
  shift; shift; shift; shift; shift
  
  while [ $# -gt 2 ]
  do
    r=$1
    string=$2
    duration=$3
    ./change.sh $int $r "$string"
    sleep $duration
    shift; shift; shift
  done
  </code></pre>
  
  <p>That works but only for one time, now I want this script to run all the time, I mean using <code>while 1</code> but that won't work this way because the argument list is empty at the end of that code!</p>
  
  <p>Is there any way to do something like the following "pseudo code" in shell scripts:</p>
  
  <pre><code>for( i=0 ; i&lt;arguments.count; i++ ){
     //do something with arguments[i]
  }
  </code></pre>
  
  <p>or copying the arguments array into another array so that I can use it later the way I want.
  I mean can I copy <code>$*</code> or <code>$@</code> or <code>arg</code> into another array?</p>
  
  <p>Any help is highly appreciated.</p>