I am running a for loop that calls in a variable from another file:
hostnames.txt
The variables in that file look like this:
export HOSTNAME_0=<hostname>
export HOSTNAME_1=<hostname>
export HOSTNAME_2=<hostname>
I am trying use them inside a for loop like this:
. hostnames.txt
for f in {0..10}; do
ssh $HOSTNAME_'{$f}'
if [$? !=0]; then
echo "Unable to SSH to server $HOSTNAME_'{$f}'"
exit 1
fi
However its not reading the value correctly, and I'm not sure what I'm missing. Would love any help.