~/ learn/ comp-325/ cards/ Loops, command grouping and a complete script
1 of 11

The same loop as while and as until

The same loop as while and as until

Answer

while [ "guess" != "secret" ] do read guess done until [ "guess" = "secret" ] do read guess done

The keyword and the operator change together. while repeats while the condition succeeds, until repeats while it fails, and the two loops here stop on exactly the same input.

S&K 3e ch12 §12.6.2–12.6.5, §12.7

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/e3e1afe9-7d76-4986-bf7e-cb2384665a70/flashcard utf-8 LF