Saying 'yes to all' using rm -i

Say I wanted to make sure I'm removing the right files first, so I did something like:

rm -i *

just to make sure that I'm okay with the files that I am removing. So this will ask me for each file. After a few files, suppose I realize it's exactly what I wanted to remove. Instead of CTRL+Cing and just doing rm *, is there a way I can just say Yes to all?

This question comes more so from curiosity rather than functionality.


Solution 1:

No.

(Unless you find a way to flip the 'interactive' bit with a debugger.)

Solution 2:

Well, this doesn't really answer your question. But instead of using rm -i, consider aliasing rm to rm -I:

The man page states:

-I     prompt once before removing more than three files, or when removing 
       recursively. Less intrusive than -i, while still giving protection 
       against most mistakes

in your ~/.bashrc, put:

 alias rm='rm -I'

this is actually useful!

Solution 3:

Is there a way I can just say Yes to all?

The answer is yes, using this code:

$ yes "yes" | rm -vRI directory

  • v: show the list of files that have been removed
  • R: remove directories and their contents recursively
  • I: as per the recommendation above.