Bash get variable at shell execution

76 views Asked by At

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.

1

There are 1 answers

0
ivanivan On BEST ANSWER

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