Skip to main content
Tweeted twitter.com/StackUnix/status/767633386437505024
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.5k
  • 205
  • 1.8k
  • 2.3k
added 68 characters in body; deleted 67 characters in body
Source Link
wsdzbm
  • 2.9k
  • 5
  • 23
  • 27

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?

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?

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?

Source Link
wsdzbm
  • 2.9k
  • 5
  • 23
  • 27

Pass command line parameters to a program inside the shell script

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?