I want to be able to run my script with one or more arguments and perform an action for all arguments passed.
So far, I have been able to run a command based on the first argument as follows:
#/bin/bash
ap=admin
lp=lender
if [[ "$1" = "ap" ]]; then
echo "### pulling $ap ###"
elif [[ "$1" = "lp" ]]; then
echo "### pulling $lp ###"
else
echo "There is no service with that name"
fi
I want to be able to run my script with more than one argument as follows and run the commands needed for each of the arguments given. For example, if I run this:
./update.sh ap lp
I want to be able to detect both ap and lp and then execute the correct commands.
To summarise, if the person running the script passes 'ap' as the argument, I want to pull admin and if the user passes both 'ap' & 'lp' as the arguments, I want to pull both admin and lender.
Thanks in advance for your help!