usually the easiest way to handle this type of script is to use the shift function.
lets say you ran the script with 3 arguments.. test1 test2 test3
Code:
#!/bin/bash
x=0
while [ ! -z $1 ]; do
$argv[$x] = $1
let x=x+1
shift
done
this would create an array with the following content:
$argv[0] = test1
$argv[1] = test2
$argv[2] = test3
This happens because shift moves the entire argument list on step in. $1 will disappear and $2 will become $1, $3 will become $2.
You don't need to use an array in the while loop, you can do a case or anything you wish, the shift statement will still do what it supposed to
ps. while [ ! -z $1 ] means while $1 is not empty keep on going ds.
Best regards
Fredrik Eriksson