How do I script a "yes" response for installing programs?

user974887 picture user974887 · Oct 4, 2011 · Viewed 143.1k times · Source

I work with Amazon Linux instances and I have a couple scripts to populate data and install all the programs I work with, but a couple of the programs ask:

Do you want to continue [Y/n]?

and pause the install. I want to auto answer "Y" in all cases, I'm just now sure how to do it.

Answer

P.T. picture P.T. · Oct 4, 2011

The 'yes' command will echo 'y' (or whatever you ask it to) indefinitely. Use it as:

yes | command-that-asks-for-input

or, if a capital 'Y' is required:

yes Y | command-that-asks-for-input