How do I pass everything but the first argument to the second bash script?

I am trying to write a bash script that executes another bash script with all but the first argument, so I cannot use:

bash abc.sh "$ @"

because it will also pass the first argument, which I don't want. How do I remove the first argument?

+3


source to share


1 answer


You can remove the first argument with shift

:

shift #same as: shift 1
bash abc.sh "$@"

      



(In bash

, ksh

and zsh

you can also use "${@:2}"

without modifying the array "$@"

, but shift

will work in any POSIX shell.)

+7


source







All Articles