I am trying to do a simple script which runs a few commands N number of times, determined by the user's input. However, when it comes to run the commands (in a for loop) - The variable is ignored:
read -p "Please enter the number of times you wish to fail over: " num
...
for run in {1..$num}
do echo "STOP: "
date
systemctl stop $broker
date
sleep $st
echo "START: "
date
systemctl start $broker
date
sleep $st
done
fi
+ '[' y == n ']'
+ '[' y == N ']'
+ for run in '{1..$num}'
+ echo 'STOP: '
STOP:
+ date
Tue Dec 4 16:14:11 GMT 2018
Can anyone explain why this is happening and what I need to do to rectify? Or does anyone have a better method for this?