題 什麼是自動按[Y]的終端命令?


對於前:如果我喜歡

sudo apt-get upgrade

然後我可能會在安裝更新之前得到y / n問題。 什麼是自動接受它的參數。


4
2018-04-16 10:40


起源


我不知道它,我會認為它會是-y,但你試過apt-get - ?看看程序本身說的是什麼? - LPChip
--yes  就是這樣 - 0xcaff


答案:


有兩種方法可以做到這一點:

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

10
2018-04-16 10:47