I am working on a shell script where it has to extract string from parameter passed. If I am passing parameters like
test.sh arg1=someArgument Arg2=AnoTherArgument
Assume user may pass the arguments with the name and value in any case,
I have to extract the parameters and manipulate, some thing like
for arg in "$@"
do
if [ lower("${arg}") == "arg1" ] then
# extract arg1's value and do something
elif [ lower("${arg}") == "arg2" ] then
# extract arg2's value and do something
fi
done
Please help me how can I extract the parameter's value in the same case that was passed?
==inside of[ ]; use a single equals sign,=, instead. Also, which shell and version are you targeting? bash 4 has parameter expansion operators built-in for converting variables to lower and upper case, without the need for external tools such as tr.