用bash脚本回车

时间:2012-04-12 08:35:40

标签: bash

通常在bash中,我会手动点击返回

[archlinux-64 ~]$ sudo pacman -S base-devel
pacman: /usr/lib/libcurl.so.4: no version information available (required by /usr/lib/libalpm.so.7)
:: There are 12 members in group base-devel:
:: Repository core
   1) autoconf  2) automake  3) binutils  4) bison  5) fakeroot  6) flex  7) gcc  8) libtool
   9) m4  10) make  11) patch  12) pkg-config

Enter a selection (default=all):

然后键入Y并在stdout的下一个提示中点击返回:

warning: make-3.82-4 is up to date -- reinstalling
resolving dependencies...
looking for inter-conflicts...

Targets (14): gcc-libs-4.7.0-4  libltdl-2.4.2-5  autoconf-2.68-2  automake-1.11.4-1
              binutils-2.22-5  bison-2.5-3  fakeroot-1.18.2-1  flex-2.5.35-5  gcc-4.7.0-4
              libtool-2.4.2-5  m4-1.4.16-2  make-3.82-4  patch-2.6.1-3  pkg-config-0.26-2

Total Download Size:    24.91 MiB
Total Installed Size:   104.95 MiB
Net Upgrade Size:       8.44 MiB

Proceed with installation? [Y/n] 

但是我已经完成了几次这个arch linux base-devel安装,我想直截了当地执行以下所有操作,并在一行bash命令中执行默认和Y.

如何在一行中编写此bash命令?

2 个答案:

答案 0 :(得分:1)

您可以通过传递--noconfirm选项来执行此操作:

pacman -S --noconfirm base-devel

如果你想摆脱下载进度条等,你也可以关闭它:

pacman -S --quiet --noprogressbar --noconfirm base-devel

查看联机帮助页:http://www.archlinux.org/pacman/pacman.8.html

答案 1 :(得分:0)

选中“是”命令。尝试使用类似的东西:

yes 'y' | my_script