Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass all but the first argument to a second bash script?

Tags:

bash

I'm trying to write a bash script that executes another bash script with all but the first argument, so I can't use:

bash abc.sh "$@"

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

like image 462
user7867665 Avatar asked Apr 14 '17 14:04

user7867665


1 Answers

You can remove the first argument with a 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.)

like image 93
PSkocik Avatar answered Oct 19 '22 20:10

PSkocik