yes Linux Commands
What is Linux yes Command?
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')
||Print help message and exit
||Print version and exit
- Print the given string repeatedly:
The above command will print hscripts repeatedly until it is killed(CTRL+C).
- 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.