I have an if statement that starts with a breaking a domain name into an array using the . as an IFS. If the array has 3 items it does one thing, if it has 2 it does another. I'm interested in the first with three items.
For www.domain.com I would get ['www', 'domain', 'com'].
I need to figure out a way to make www or array[0] one var and combine domain and com or array[1] and array[2] into another var. I've tried but I'm new to this and can't figure it out nor can I find how it do it online.
My if statement code works great:
input=$1
IFS='.' read -r -a domain_dot <<< "$input"
if [ ${#domain_dot[@]} == 3 ]; then
echo "One"
else
echo "Two"
fi