As for ./script.sh arg1 [arg2 arg3 ...]
, the command line arguments arg1
, arg2
, ... can be got by $1
, $2
, ... But the number of arguments is NOT fixed.
In the shell script, I want to pass the arguments starting from arg2
to a program,
#/bin/bash
...
/path/to/a/program [I want to pass arg2 arg3 ... to the program]
...
How could I do it since there could be one or more arguments?
$@
? – wsdzbm Aug 21 '16 at 23:48$@
tells the shell to double-quote each parameter (something nice to do if the parameters contain interesting characters such as parentheses or asterisks). If you don't care about that, a plain$*
works... – Thomas Dickey Aug 21 '16 at 23:50