Biostar Beta. Not for public use.
Question: Problem with using "until" in "bash script"
0
Entering edit mode

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

ADD COMMENTlink 2.9 years ago Afagh • 70
Entering edit mode
1

You're confused with the while loop.

ADD REPLYlink 2.9 years ago
Benn
6.9k
Entering edit mode
Entering edit mode
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 2.9 years ago
Jean-Karim Heriche
19k
Entering edit mode
0

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

ADD REPLYlink 2.9 years ago
Benn
6.9k
Entering edit mode
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 2.9 years ago
Lars Juhl Jensen
11k
This thread is not open. No new answers may be added
Similar Posts
Loading Similar Posts
Powered by the version 2.0