Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


Search this Thread
Old 02-19-2004, 02:40 PM   #1
Registered: Dec 2003
Location: Earth... I think!?
Distribution: Debian
Posts: 32

Rep: Reputation: 15
bash - while + until loops grouping?

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.

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

Old 02-19-2004, 03:23 PM   #2
Registered: Sep 2003
Location: Paris, France
Distribution: Arch x86_64
Posts: 221

Rep: Reputation: 30
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.
Old 02-19-2004, 03:29 PM   #3
Registered: Dec 2003
Location: Earth... I think!?
Distribution: Debian
Posts: 32

Original Poster
Rep: Reputation: 15
Thanks for a quick reply!
I see now


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash, LS, For loops, and whitespaces in directories jhrbek Programming 27 09-22-2010 06:17 AM
Bash For Loops gives syntax error meadensi Linux - Newbie 2 02-23-2005 11:30 AM
bash scripting and loops phoeniks Programming 5 01-24-2005 05:00 PM
bash, loops and spaces in filenames shy Programming 5 11-08-2004 08:43 AM
bash scripting - referring to external arguments into loops linsson Linux - General 2 07-23-2004 01:24 PM

All times are GMT -5. The time now is 06:47 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration