0

There is a method to get a variable with the bash execution command?

Example:

./exec.sh var1 var2

or with arguments

./exec.sh -x var1 -y var2

I looked for "Get variable at bash execution" but nothing.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Northumber
  • 315
  • 2
  • 3
  • 15

1 Answers1

1

As the comment mentions, $1, $2, etc are positional variables for the arguments. But there are lots more, very useful ones too like $# for the number of arguments passed, etc. More info at

http://wiki.bash-hackers.org/syntax/shellvars

ivanivan
  • 2,155
  • 2
  • 10
  • 11