I have a for loop like the below. I want to know if it is possible to check through all previous iterations of a for loop?
Where I am on the fourth iteration and $i is 4:
for ((i=1;i<9;i++)); do #$i is currently 4
while (($x == 3)) || (($x == 2)) || (($x == 1)); do
echo "Something"
done
done
But when $i is 5:
for ((i=1;i<9;i++)); do #So $i is now 5
while (($x == 4)) || (($x == 3)) || (($x == 2)) || (($x == 1)); do
echo "Something"
done
done
Is it possible to check all previous iterations like the above in a more simple way? I know I could check with $i-1 $i-2
but how do I code when to stop?