#!/bin/bash # Folks I wrote this to show the difference between the # manipulation of $arg which loads the scripts input # parameters in; a variable being incremented i, # and finally using $1 and shift as a combo to # walk through the input arguments to the script # Here is an example of running the script with input: # #$ ./shift.sh one two three four # # # First let's print the scripts environmental variables: echo $0 is the name of the script echo $# is the number of parameters entered by the user echo $$ is the process ID echo $@ is the list of parameters entered # and the output # #This is the arg value one #This is the variable value 0 #This is the $1 value one #This is the arg value two #This is the variable value 1 #This is the $1 value two #This is the arg value three #This is the variable value 2 #This is the $1 value three #This is the arg value four #This is the variable value 3 #This is the $1 value four i=0 # variable i increment using let for arg in $@ # you don't need in $@ because by default it is that do echo This is the arg value $arg echo This is the variable value $i echo This is the '$1' value $1 let i=i+1 shift done