Apologies if this has been answered previously, but I couldn't find much online.
Here's what I'm trying to accomplish:
if [[ "${hostname}" = (foo | bar)servername(01 | 02 | 03) ]]; then var="foobarfoo"
fi
With this any of the following would meet the criteria: fooservername01, barservername02, fooservername03, barservername03, etc.
I've accomplished this in a much more inefficient fashion:
if [[ ${hostname} == "fooservername01" ]] || [[ ${hostname} == "fooservername02" ]] || [[ ${hostname} == "fooservername03" ]] || [[ ${hostname} == "barservername01" ]] || [[ ${hostname} == "barservername02" ]] || [[ ${hostname} == "barservername03" ]]; then var="foobarfoo"
fi
But I am looking to optimize/streamline the code.
Any insight would be appreciated as I'm still very new to bash scripting and even scripting in general.
TIA