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
  • 77,979
  • 13
  • 71
  • 125
Northumber
  • 195
  • 1
  • 2
  • 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,102
  • 2
  • 10
  • 10