linux自动应答yes命令,“yes”命令是什么?

问题描述

我在Ubuntu终端中发出了一个命令,要求我键入yes,但是我发现它只在第一次问我,但是我在意识到之前已经按Enter键了。因此,我希望收到“找不到命令”消息,但是我得到了”y”s的never-ending流。这似乎是它唯一要做的事情,所以我想知道此命令的意义是什么,为什么它输出”y”s? (Ubuntu 11.10)

最佳回答

By itself, the yes command outputs ‘y’ or whatever is specified as an argument, followed by a newline repeatedly until stopped by the user or otherwise killed; when piped into a command, it will continue until the pipe breaks (i.e., the program completes its execution).

It can also be used to test how well a system handles high loads, as using yes results in 100% processor usage, for systems with a single processor (for a multiprocessor system, a process must be run for each processor). This, for example, can be useful for investigating whether a system’s cooling system will be effective when the processor is running at 100%.

次佳回答

很久以前(SySV天或更早),fsck命令没有-y或-n选项。该命令将以交互方式要求您更改成百上千个项目,期望为’y’或’n’。创建yes命令是为了将其传递给fsck,以及一些其他程序可以重复回答交互式问题(同样,这是SysV天,早于Tcl和Expect)。 yes程序非常符合UNIX的哲学:小型程序可以很好地完成特定的任务并与其他程序一起工作。

第三种回答

Linux / Unix Command: yes

NAME

yes – output a string repeatedly until killed

SYNOPSIS

yes [STRING]… yes OPTION

DESCRIPTION

Repeatedly output a line with all specified STRING(s), or `y’.

–help display this help and exit –version output version information and exit

SEE ALSO

The full documentation for yes is maintained as a Texinfo manual. If the info and yes programs are properly installed at your site, the command

info yes

should give you access to the complete manual.

以我的拙见,当您必须通过按”y”键重复授权进程/脚本中的某些内容时,使用”yes”命令听起来很合逻辑。可以通过取消程序执行来控制。

无论如何,其他人可能有使用此命令的经验。

参考资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值