I have a directory with folders sequentially numbered 1-1000, however I want to perform an action for some of the folders in this directory. i.e folders 1-50. How do I define the start and end point of the loop? So far I have a script along these lines:a=1b=1for i in ~/PATH/*/ ;do(cd $i/ && action)echo completeda=`expr $a + $b`echo Next FolderdoneI can define the start of the loop by changing a= but I am not sure how to define the end to the loop? As it stands, it will keep going through all the folders in that directory. Thanks :)
Defining the start and end point of a loop in bash
bash
#!/bin/basha=1b=1cd ~/PATH/for i in $(ls -v) ;do  (cd $i/ && action) && echo completed || echo error  a=$((a+b)); [ $a -gt 50 ] && break   echo Next Folderdone