Calvin Cheng
Calvin Cheng

Reputation: 36506

Scripting a carriage return in bash

so normally in bash, I would manually hit return

[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):

and followed by keying in Y and hitting return in the next prompt in 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] 

But having done this arch linux base-devel installation a couple of times, I would like to get straight to the point and execute all of the following with default and Y in one single line of bash command.

How would I write this bash command in one single line?

Upvotes: 0

Views: 758

Answers (2)

ArjunShankar
ArjunShankar

Reputation: 23670

You can do this by passing the --noconfirm option:

pacman -S --noconfirm base-devel

If you want to get rid of the download progressbar, etc you can switch that off too:

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

Check out the manpage: http://www.archlinux.org/pacman/pacman.8.html

Upvotes: 1

Ivaylo Strandjev
Ivaylo Strandjev

Reputation: 70931

Check the 'yes' command. Try using something like:

yes 'y' | my_script

Upvotes: 0

Related Questions