Question: (Closed) Problem with using "until" in "bash script"
0
gravatar for Afagh
2.8 years ago by
Afagh80
United states
Afagh80 wrote:

I don't understand why it doesn't print 0 :

z=0 until (($z < 1)) do echo $z done

I don't understand why it prints 2 (2 is not less than 1) : output:

z=2 until (($z < 1)) do echo $z done

output:2

bash • 621 views
ADD COMMENTlink written 2.8 years ago by Afagh80
1

You're confused with the while loop.

ADD REPLYlink written 2.8 years ago by Benn7.9k
1

BASH has an until loop: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_03.html

ADD REPLYlink written 2.8 years ago by pld4.8k
1

From that link:

The until loop is very similar to the while loop, except that the loop executes until the TEST-COMMAND executes successfully. As long as this command fails, the loop continues.

By the way this is not a bioinformatics question.

ADD REPLYlink written 2.8 years ago by Jean-Karim Heriche21k

Yeah that's what I mean, it is kind of the opposite of while loop. OP seemed to expect while behavior.

ADD REPLYlink written 2.8 years ago by Benn7.9k
1

Hello Afagh!

We believe that this post does not fit the main topic of this site.

Not a bioinformatics question

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink written 2.8 years ago by Lars Juhl Jensen11k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1619 users visited in the last hour