The yes
command is used to output y, or whatever word you choose, forever. 🔁
The yes
command outputs the same string, STRING, in a constant stream. If STRING is not specified, the word it repeats is y. 🔁
yes
dates back to a time before Unix commands included the "force" (-f) option, which for many commands is the same as answering "yes" to all prompts.
yes
can be used to do something very similar: if the output of yes is piped to a command, it will effectively answer "yes" to any confirmation prompts.
yes [STRING]...
y
y
y
y
y
y
.
.
.
yes
can be dangerous also. If you redirect the output stream of yes
to a file, it will eat up your storage space. 💣
$ yes >> yes.txt
^Z
$ du -h yes.txt
1007M yes.txt
I ran the command only for 10 Seconds. And It consumed almost 1 GB. 💥
yes
takes an argument and prints it infinitely. What if you take yes
as argument itself. 💣
$ yes `yes`
You tell me what happens. 😜