Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the point of the coreutils program 'yes'?

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.

like image 743
saintlyRook Avatar asked Sep 07 '14 19:09

saintlyRook


People also ask

What is the point of the yes command?

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.

What does the yes command do in Linux?

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.

How do you give yes to a command?

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 *.


2 Answers

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.

like image 56
Basile Starynkevitch Avatar answered Sep 28 '22 20:09

Basile Starynkevitch


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

like image 41
maskacovnik Avatar answered Sep 28 '22 18:09

maskacovnik