Some commands - like rm -i
, find -ok
, and so on - ask users to
answer a "do it or not?" question from the keyboard.
For example, you might use a file-deleting program named del
asks before deleting each file:
If you answer
, then the file will be deleted.
What if you want to run a command that's going to ask you 200 questions
and you want to answer
to all of them, but you don't want to type
's in from the keyboard?
Pipe the output of
to the command; it will answer
yes | del *
If you want to answer
to all the questions, you can do:
yes n | del *
Not all UNIX commands read their standard input for answers to prompts.
If a command opens your terminal
directly to read your
knows how to say more than just y
shows how to test a terminal with yes
The CD-ROM has GNU's yes