Print the command line argument(s), separated by spaces and followed by a newline, forever until killed. When piped into a command, it will continue until the pipe breaks (i.e., the program completes its execution).
Syntax yes text yes --help yes --version Key text The text to repeat --help Display help --version Display the version no. If no arguments are given, prints `y' followed by a newline forever until killed.
yes in conjunction with head can be used to generate large test files. For example, executing
yes 123456789 | head -1000 > file.txt
results in a file with 1000 lines each consisting of 10 characters (1, 2, 3, 4, 5, 6, 7, 8, 9 and newline).
Using yes results in 100% processor usage, for this reason it is rarely used other than for testing e.g. to max out a computer’s CPU.
Related linux commands: