yes:tldr:a6105
The command "yes" is a simple Linux command that continuously outputs "yes" as its default behavior. It is often used to provide an automatic affirmative response to a command or script that requires user confirmation.
By default, when you run the "yes" command, it will display "yes" repeatedly until you manually terminate the command. You can run it without any arguments like this:
$ yes
The output will look something like this:
yes
yes
yes
...
One practical use of the "yes" command is when you want to automate the confirmation of a command that may prompt for user input. For instance, if you want to delete multiple files without being asked to confirm each deletion, you can combine the "yes" command with the "rm" (remove) command like this:
$ yes | rm -i file1 file2 file3
In this example, the "yes" command produces an unending stream of "yes" responses, which is then piped to the "rm -i" command. The "-i" flag makes "rm" prompt for confirmation before deleting each file, but since "yes" is providing a continuous stream of "yes" responses, it effectively automates the confirmation process, deleting all files without manual intervention.
Keep in mind that the "yes" command can also be used creatively for demonstration or testing purposes, such as generating large amounts of sample data or simulating user input in specific scenarios.