Inside my bash script, I would like to parse zero, one or two parameters (the script can recognize them), then forward the remaining parameters to a command invoked in the script. How can I do that?
shift built-in command to "eat" the arguments. Then call the child process and pass it the
"$@" argument to include all remaining arguments. Notice the quotes, they should be kept, since they cause the expansion of the argument list to be properly quoted.
bash uses the shift command:
#!/bin/bash echo $1 shift echo $1 $2
shifttest.sh 1 2 3 produces
1 2 3