LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   bash - while + until loops grouping? (https://www.linuxquestions.org/questions/linux-general-1/bash-while-until-loops-grouping-148095/)

trees 02-19-2004 01:40 PM

bash - while + until loops grouping?
 
Greetings,
I'm writing a simple backup script and need to use two loops.
How can I include a loop within a loop?
With the following, the program stalls at the end, it apparantly doesn't like the two done's next to each other.

x=1
while [ -f test ]
do
until [ $x "=" 5 ]
do
echo $x " - not 5 yet!"
let x=x+1
done
done

:Pengy:
thanks!

jib2 02-19-2004 02:23 PM

your nested loops are ok.
the program doesn't stall, it keeps running on the 1st loop: at the end of the 2nd loop, the file still exists but x=5 already, so the echo command isn't reached.

trees 02-19-2004 02:29 PM

Thanks for a quick reply!
I see now :)


All times are GMT -5. The time now is 04:37 AM.