Question: (Closed) Problem with using "until" in "bash script"
0
gravatar for Fatima
3.7 years ago by
Fatima860
United states
Fatima860 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 • 708 views
ADD COMMENTlink written 3.7 years ago by Fatima860
1

You're confused with the while loop.

ADD REPLYlink written 3.7 years ago by Benn8.0k
1

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

ADD REPLYlink written 3.7 years ago by pld4.9k
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 3.7 years ago by Jean-Karim Heriche24k

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

ADD REPLYlink written 3.7 years ago by Benn8.0k
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 3.7 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: 1070 users visited in the last hour