It’s usually used as a quick and dirty way to provide answers to an interactive script:
yes | rm -r large_directory
will not prompt you about any file being removed. Of course in the case of
rm, you can always supply
-f to make it steamroll the directory removal, but not all tools are so forgiving.
A more relevant example of this that I recently came across is when you are
fscking a filesystem and you don’t want to bother answering
y when prompted before fixing each error:
yes | fsck /dev/foo
Beside the main point mentioned in the previous answer the
yes command can also be used to test high loads of CPU on a system.
yes creates a process which acts as a dummy CPU loader and results in 100% processor usage. http://en.wikipedia.org/wiki/Yes_(Unix)
When updating ports on a FreeBSD workstation, using portmaster + yes becomes very handy:
yes | portmaster -da
That way you can let the machine update while you lunch and all the questions fill default to ‘y,yes’
When rebuilding the world for ‘make delete-old’ and ‘make delete-old-libs’.
this is a big time saver:
yes | make delete-old
yes | make delete-old-libs
Basically helps you to avoid typing / confirm certain operations that ask for a ‘y’ or ‘yes’