Forrest logo
back to the yes tool

yes:tldr:a6105

yes: Repeatedly output "y".
$ yes
try on your machine

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.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the yes tool