All it does is repeat the first argument over and over?
Is this just some kind of quirky 'Easter egg' or is there a use to it. The man page is sparse to say the least.
The yes command outputs an affirmative response repetitively. Use the yes command as piped input to another command that requires an affirmative response before it completes the specified action. For example, the yes command is useful when deleting multiple files from a directory.
yes is a command on Unix and Unix-like operating systems, which outputs an affirmative response, or a user-defined string of text, continuously until killed.
Ans: Lets say that we want to delete all the . txt file present in the current directory. Instead of writing rm -i *. txt and then typing y at the end for every file, what we can do is we can use yes | rm -i *.
Some programs, e.g. find(1) with its -ok
option, or rm(1) with its -i
option, etc.... are asking yes/no questions. Some scripts might use these programs with these options.
So it is sometimes convenient to pipe the output of yes
into these programs or scripts.
So the answer is that sometimes (but quite rarely) yes
is useful. I'm probably using it about once or twice a year.
BTW, it might perhaps be useful in your own scripts or piping commands. It might also be useful for benchmarking purposes.
Program yes is used for testing / learning
I used it for example in school when we learned about killing processes
It is fastest way to use infinite loop :D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With