Skip to content

yes Command Cheat Sheet

yes outputs a string repeatedly until killed. It is most often used to automate scripts that require interactive confirmation.


Synopsis

yes [STRING]...

Basic Usage

Default (Print 'y')

yes
# Output:
# y
# y
# y
# ... (forever)

Custom String

yes "no"

Automating Prompts

Auto-Accept (Press 'y')

If a command asks "Are you sure? [y/N]", pipe yes to it.

yes | rm -i *.txt

Auto-Decline (Press 'n')

yes n | some_interactive_script.sh

Automate Default Answers (Press Enter)

Use yes with an empty string to send "Enter" repeatedly.

yes "" | install_script.sh

Testing & Load Generation

Generate High CPU Load

Running yes consumes 100% of a single CPU core.

yes > /dev/null &
(Warning: Use with caution! Kill with killall yes)

Create Large Dummy Files

# Create a 100MB file full of 'y's
yes | head -c 100MB > hugefile.txt

Notes

  • modern alternatives: Many commands have a built-in -y or --force flag (e.g., apt -y install, rm -f) which is preferred over piping yes. Use yes for legacy commands or scripts lacking non-interactive modes.