Learner Learner - 2 months ago 15
Linux Question

No equivalent of Yes

yes
command in linux prints
y
infinitely on the console. This is helpful to respond to few interactive commands with
y
. For e.g.
yes | cp A/*.txt B
automatically overwrites all files in destination directory.

Is there an equivalent command in linux that prints
n
infinitely?

Answer Source

yes accepts an argument, y is just the default value.

You can use:

yes n | command

How cool is that?


Pro tip:

# Use this and see what happens
yes maybe | command

Note: Not every command implements maybe.