and then include that in a loop
How?
this what I have so far
Code: Select all
repetitions=8
for g in {repetitions..1}
do
stuff to do here
done
Code: Select all
repetitions=8
for g in {repetitions..1}
do
stuff to do here
done
Code: Select all
# echo {1..8}
1 2 3 4 5 6 7 8
# i=8
# echo {1..$i}
{1..8}
# eval echo {1..$i}
1 2 3 4 5 6 7 8
# for j in $(eval echo {1..$i}) { echo j=$j; }
bash: syntax error near unexpected token `}'
# for j in $(eval echo {1..$i});do echo j=$j; done
j=1
j=2
j=3
j=4
j=5
j=6
j=7
j=8
# for ((j=0;j<i;j++)){ echo j=$j; }
j=0
j=1
j=2
j=3
j=4
j=5
j=6
j=7
Code: Select all
for g in {repetitions..1}
Code: Select all
for g in {22..1}
Code: Select all
n=21 #no of repetitions
for g in $(eval echo {1..$n}); do echo "Hello $g times"; done
Code: Select all
# for g in $(eval echo {$repetitions..1}); do echo g=$g; done
g=21
g=20
...
g=2
g=1
Code: Select all
# for ((g=repetitions; g > 0; g-- )) { echo g=$g; }
g=21
g=20
...
g=2
g=1
Code: Select all
# for g in $(seq 21 -1 1); do echo g=$g; done
g=21
g=20
...
g=2
g=1
Code: Select all
# n=21
Code: Select all
# echo $n
21
Code: Select all
# (( answer=n+repetitions ))
# echo $answer
42
Code: Select all
# echo $(( n + repetitions ))
42
Code: Select all
#!/bin/bash
for ((i=0;i<8;i++))
do
echo $i
done