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.
yes
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:
#!/bin/bash
read AAA
read BBB
read CCC
echo "$AAA, $BBB, $CCC"
Now, try to execute our script with yes in pipe:
yes | ./read.sh
If you want o give opposite answer to our script, it is possible. Just pass string argument to yes:
yes n | ./read.sh
If script expect capital 'Yes' use:
yes Yes | ./read.sh
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.
We prepared for you video course Marian's BASH Video Training: Mastering Unix Shell, if you would like to get much more information.
Thank you. Marian Knezek