I have a bash script called foo with variable number of arguments, with the first one being a required one, i.e.:
foo a1 b2 b3 b4 ...
I understand that in bash $1 will get me argument a1, but is there a way to get all the rest of the arguments? $@ or $* seem to get me all the arguments including a1.
./foo.sh 1 2 3 4
Will output:
Slice the
$@
array.shift
will shift all the parameters, running the previous example would give:You can use shift command for that. That will remove $1 and you can access the rest of arguments starting with $1.