Suppose I have a bash script scr.sh
. Inside this script I have a variable $x
. I need to setup the following behavior. If scr.sh
is called with an argument, as in:
./scr.sh 45
then I want x
to be assigned to this value inside my bash script. Otherwise, if there is no command line argument, as in:
./scr.sh
x
should be assigned to some default value, which in my case is an environment variable, say x=$ENVIRONMENT_VAR
.
How can I do this?