LinuxCommandLibrary

yes

TLDR

Output 'y' repeatedly (for auto-confirming prompts)

$ yes | [command]
copy
Output a custom string repeatedly
$ yes "[custom text]"
copy
Auto-answer 'no' to all prompts
$ yes n | [command]
copy
Output for a limited number of lines
$ yes | head -n [10]
copy

SYNOPSIS

yes [string]

DESCRIPTION

yes outputs a string repeatedly until killed or the pipe closes. By default, it outputs "y" followed by a newline, endlessly.
The primary use is piping to commands that ask for confirmation, automatically answering "y" (or any specified response) to all prompts. This is useful for scripting commands that don't have native batch/quiet modes.
When the receiving command closes its stdin (by exiting), yes terminates automatically due to the broken pipe.
Without piping, yes runs indefinitely and must be interrupted with Ctrl+C.

PARAMETERS

string

String to output repeatedly (default: "y")
--help
Display help and exit
--version
Display version and exit

EXAMPLES

$ # Auto-confirm all prompts
yes | apt upgrade

# Auto-answer 'no'
yes n | rm -i *.txt

# Generate test data
yes "test line" | head -1000 > test.txt

# Stress test (generates output as fast as possible)
yes > /dev/null
copy

CAVEATS

Using yes bypasses safety prompts. Ensure you understand what you're auto-confirming before piping yes to destructive commands.
Some commands detect non-interactive input and refuse to run or behave differently. Use command-specific flags (like -y or --yes) when available.
Yes runs at maximum speed, which can generate significant CPU load when not piped to anything useful.

SEE ALSO

true(1), false(1), seq(1), timeout(1)

Copied to clipboard