bash while until the cycle usage

First, bash command executed successfully returns a status code 0, else return non-zero status code (hereinafter, the terminal prompt $)
$ true; echo $?
0
$ false; echo $?
1

1. while

$ while true; do echo good; break; done
good
$ while [ 1 -eq 1 ]; do echo good; break; done
good
$ while ps -ef | grep grep; do echo good; break; done
good

2. useful

$ until false; do echo good; break; done
good
$ until [ 1 -ne 1 ]; do echo good; break; done
good
$ until ps -ef | grep grep | grep -v grep; do echo good; break; done
good

Thus, while if the condition is true then expressed into the circulation, until the condition is true not expressed into the circulation.

Guess you like

Origin www.cnblogs.com/lyg-blog/p/11746329.html