in my bash script I try to use a number as an input variable for
a for loop
I run the script as
./script.sh InputFolder/ Number_of_iterations
the script should work inside the given folder and run a for loop as many times as the Number_of_iterations
variable is set to.
But somehow I can't set the variable as an integer.
this is an example of my loop in the script:
for i in {1..$(($2))}
do
echo "Welcome $i times"
done
I have tried already the double brackets $(($...))
option as well as the double quotations "..."
, but the output I keep getting is
Welcome {1..5} times
which make me think, this is not an integer. I would appreciate any help in reading the input parameter as an integer into the script.
for i in $(eval echo "{1..$2}"); do
– Mikael Kjær Jan 22 '18 at 10:29