Have you ever wondered to input the arguments in the bash scripts. Well there is the process how you do it.
Step 1: add the following script on the top of bash script file (test.sh)
# passing the arguments
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
v="${1/--/}"
declare $v="$2"
fi
shift
done
echo $appName $version # this one is passed as an arguments
Step 2: pass the name of variable that you want to access in as an arguments something like this
./test.sh –-appName App1 –-version v1.2
What a great way isn’t it?
I bet this is the one I was looking for it this code made my script work as expected
Thanks, I am glad it helped you!