2012-04-12 107 views
0

因此通常在bash回車,我將手動擊中Y中鍵控,打在了下一個提示在標準輸出返回返回使用腳本在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): 

和遵循:

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命令寫入一行?

回答

1

您可以通過傳遞--noconfirm選項做到這一點:

pacman -S --noconfirm base-devel 

如果你想擺脫的下載進度,等您可以切換斷過:

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

退房手冊頁:http://www.archlinux.org/pacman/pacman.8.html

0

檢查'是'命令。嘗試使用類似:

yes 'y' | my_script 
+0

昂貴,但搞笑 – dylnmc 2015-11-09 01:36:09