until
秃噜豆儿 发表于 2020-07-17 15:59浏览次数:
在Unix-like的操作系统上,until和while是shell的函数,用于定义代码块和条件语句。
如果使用while,只要条件为真,块就会循环。当条件为false时,循环终止。
如果使用until,只要条件为false,块就会循环。当条件为真时,循环终止。
On Unix-like operating systems, until and while are functions of the shell that define a block of code, and a conditional statement.
If while is used, the block loops as long as the condition is true. When the condition is false, the loop terminates.
If until is used, the block loops as long as the condition is false. When the condition is true, the loop terminates.
目录:
1 until 运行系统环境
2 until 语法
3 until 示例
until 运行系统环境
until 语法
while [conditions] ; do actions; done
until [conditions] ; do actions; done
while [conditions] ; do actions; done
until [conditions] ; do actions; done
until 示例
filename=anything
while [ $filename ]
do
echo "file?"
read filename # read from terminal find . -name $filename -print
done
反复提示用户输入要定位的文件名,直到用户选择完成执行为止。
filename=anything
while [ $filename ]
do
echo "file?"
read filename # read from terminal find . -name $filename -print
done
User is repeated prompted for a name of a file to be located, until the user chooses to finish execution.