yes
秃噜豆儿 发表于 2020-07-03 16:08浏览次数:
在Unix-like的操作系统上,yes命令用于连续输出“y”,直到它被中止。
On Unix-like operating systems, the yes command is used to output "y", continually, until it is aborted.
目录:
1 yes 运行系统环境
2 yes 描述
3 yes 语法
4 yes 选项
5 yes 示例
yes 运行系统环境
yes 描述
yes命令以恒定流输出相同的字符串STRING。如果未指定STRING,则重复的单词为“ y”。
yes可以返回到Unix命令包含“ force”(-f)选项之前的时间,对于许多命令,该选项与对所有提示回答“ yes”相同。
yes可以用于执行非常相似的操作:如果是,则输出通过管道传递到命令,依次对任何确认提示有效地回答“ yes”。
The yes command outputs the same string, STRING, in a constant stream. If STRING is not specified, the word it repeats is "y".
yes dates back to a time before Unix commands included the "force" (-f) option, which for many commands is the same as answering "yes" to all prompts.
yes can be used to do something very similar: if the output of yes is piped to a command, it will effectively answer "yes" to any confirmation prompts.
yes 语法
yes [STRING]...
yes [OPTION]
yes [STRING]...
yes [OPTION]
yes 选项
--help
|
显示帮助消息,然后退出。
|
--version
|
显示版本信息,然后退出。
|
--help
|
Display a help message, and exit.
|
--version
|
Display version information, and exit.
|
yes 示例
yes | rm -i *.txt
从当前目录中删除扩展名为.txt的所有文件。在这里,输出一个“是的,在删除文件之前,会有一个rm-y的常量,并在这个输出前提示”是“是的”。yes命令中的y字符将对每个提示自动响应“yes”。
yes n | rm -i *.txt
在这里,yes命令以恒定的流向rm-i命令输出“n”,对所有相同的问题回答“no”。因此,此命令不删除任何文件。
yes | rm -i *.txt
Removes all files with the extension .txt from the current directory. Here, yes outputs a constant stream of "y" characters, and that output is piped to the rm -i command, which prompts for confirmation before deleting each file. The y characters from the yes command will respond "yes" to each prompt automatically.
yes n | rm -i *.txt
Here, the yes command outputs "n" in a constant stream to the rm -i command, answering "no" to all the same questions. Therefore, this command deletes no files.