yes Linux Commands

What is Linux yes Command?



yes command repeatedly prints the given string separated by a space and followed by a newline until it is killed. If no string is given, it just prints 'y' repeatedly until it is killed. It is normally used in scripts, its output is piped to a command or program that prompts you to do this or that (do you want to delete this file press 'y' or 'n')


yes [string..]
yes [options..]


--help Print help message and exit
--version Print version and exit


  1. Print the given string repeatedly:
    yes "hscripts"

    The above command will print hscripts repeatedly until it is killed(CTRL+C).
  2. To delete a file without pressing any key when it prompts:
    yes | rm -i *.txt

    In the above example, the yes command is piped with rm command. Normally rm -i will prompt you to remove the file, to remove the file you have to type either y(yes) or n(no). When it is piped with yes by default, the yes will print y and all the txt files will be removed automatically, so that you dont need to type y for every txt files.
    yes n | rm -i *.txt
    The above example says not to remove a file when rm -i prompts to remove the file.

Ask Questions

Ask Question