I have a script "/tmp/SampleScript.sh" with below content:
echo "First arg: $1"
echo "Second arg: $2"
If I run this script as below:
[oracle@xxxxx tmp]$ ./SampleScript.sh FirstParamPassed SecondParamPassed
Output Is:
First arg: FirstParamPassed
Second arg: SecondParamPassed
But if i run this as:
[oracle@xxxxx tmp]$ ./SampleScript.sh SecondParamPassed FirstParamPassed
Output Is:
First arg: SecondParamPassed
Second arg: FirstParamPassed
I want output like this:
echo "First arg: $FirstParamPassed"
echo "Second arg: $FirstParamPassed"
[oracle@xxxxx tmp]$ ./SampleScript.sh SecondParamPassed=2 FirstParamPassed=1
First arg: 1
Second arg: 2
How can I use this type of named variable in REHL shell script. I have gone through this answer Is there a way to avoid positional arguments in bash? but unable to understand how to implement in my case.