bash yes to all


You remember when Homer Simpson worked at home? Long did not enjoy it. Therefore he is represented by birds, which automatically screen by pressing "y" key. How could this be done in BASH?

Yes command inserts the "y" character of STDIN infinitely times.


You can use it in way of STDIN redirection to another command:

yes y | command

Let's write small script, that will expect three lines of text from you:

read AAA
read BBB
read CCC
echo "$AAA, $BBB, $CCC"

Now, try to execute our script with yes in pipe:

yes | ./

If you want o give opposite answer to our script, it is possible. Just pass string argument to yes:

yes n | ./

If script expect capital 'Yes' use:

yes Yes | ./

Some commands have an "assume-yes" flag '-y', for examples: yum, apt-get.

Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.