Answering Terminal Prompts/Warnings Automatically

A quick tip for automating those terminal prompts or warnings that you may get while, for example, overwriting files during a ‘cp’ command, is to use the ‘yes‘ command which will “be repetitively affirmative”. Use it like this:

yes | cp -r foo/ bar/

The ‘yes’ command will output whatever you want forever as well. For example, if you wanted to say “no” to all prompts or warnings, you would simply use…

yes n | cp -r foo/ bar/

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:

There's 2 Comments So Far

  • gentooROCKS!
    April 10th, 2010 at 8:27 am

    hah, I’ve always been wondering what “yes” could be useful for. Now I know. 🙂 Thought, it was made for generating lots of output like for network or I/O
    performance tests.


  • [email protected]
    April 10th, 2010 at 9:38 am

    Those are good ideas too!

Share your thoughts, leave a comment!