Back to the command reference

yes

ShellFundamentals In simulator In real Linux

Print y (or a string) forever

Name: yes

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

yes prints y (or a given string) over and over until it is killed or the pipe closes. Feed it to a command that keeps asking for confirmation to answer automatically.

Syntax

yes [STRING]

Common options

STRINGPrint STRING over and over (y by default), e.g. yes n | cmd

Examples

  • $ yes | sudo apt install vim

    Answer yes to every prompt

    Explain
  • $ yes hello | head -3

    Print hello 3 times

    Explain

Related