3

On my Linux 4.15 machine I found the yes command that appears completely useless - it outputs a string passed as argument (default: 'y') repeatedly untill killed. And... that's it.

name@machine:~$ yes
y
y
[...]
y
y
^C

I have trouble figuring out a possible use case for this, especially given that a simple while true; do echo y; done has similar behavior and is more readable (but I can't find any case for it either).

What can this command be used for? Where does it comes from? Neither the man page nor the full doc answer these questions!

  • 1
    If you're running a command or script that is going to prompt you for multiple confirmations, you can pipe yes into it and it automatically answer y without the need for any further interaction on your part. – n8te May 9 at 22:39
7

The command is used to automate scripts of programs where you have a prompt waiting for user input in the form of "press 'y/n' to continue". But there are also other use cases.

See What is the point of the “yes” command?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.