Practice 1
The given shell program lists parameters which are passed to the program, with the number of the parameter.
# vi whileparam count=1
while [ -n "$*" ]
do
echo "This is parameter number $count $1"
shift
count='expr $count + 1'
done
# sh while 1 2 3 4 5 6
This is parameter number 1 1
This is parameter number 2 2
This is parameter number 3 3
This is parameter number 4 4
This is parameter number 5 5
This is parameter number 6 6
The above program will accept the arguments and show the respective position of every argument or parameter. In the program the shift command has been used to shift the parameter to next position.