Linux UNIX yes 命令重复输出y

On Unix-like operating systems, the yes command is used to output "y", continually, until it is aborted.

This document covers the GNU/Linux version of yes.

Description

The yes command outputs the same stringSTRING, 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.

Syntax

yes [STRING]...
yes [OPTION]

Options

--helpDisplay a help message, and exit.
--versionDisplay version information, and exit.

Examples

yes | rm -i *.txt

Removes all files with the extension .txt from the current directory. Here, yes outputs a constant stream of "ycharacters, 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 -icommand, answering "no" to all the same questions. Therefore, this command deletes no files.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值