例如:如果我喜欢
sudo apt-get upgrade
那么在安装更新之前我可能会收到 y/n 问题。自动接受它的参数是什么。
答案1
有两种方法可以做到这一点:
Apt-get 具体内容:
$man apt-get
[...]
-y, --yes, --assume-yes
Automatic yes to prompts; assume "yes" as answer to all prompts
and run non-interactively. If an undesirable situation,
such as changing a held package, trying to install a unauthenticated
package or removing an essential package occurs then apt-get will abort.
[...]
--force-yes
Force yes; this is a dangerous option that will cause apt to continue
without prompting if it is doing something potentially harmful.
It should not be used except in very special situations.
Using force-yes can potentially destroy your system!
常规:yes
命令:
$man yes
yes - output a string repeatedly until killed [...]
DESCRIPTION
Repeatedly output a line with all specified STRING(s), or 'y'.
由于yes
无法了解内部情况,因此apt-get
它可能等同于--force-yes
危险的。如果您仍想这样做,可以将 的输出通过管道传输yes
到 中apt-get
:
yes | apt-get update