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.
17 Answers
No.
(Unless you find a way to flip the 'interactive' bit with a debugger.)
5Well, 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 mistakesin your ~/.bashrc, put:
alias rm='rm -I'this is actually useful!
0Is 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.
Just check first using ls *.bla and then rm -f *.bla maybe?
Use caution!
1If you are running in screen (a good idea in general), you can do:
ctrl-a : exec .! yes yThis would cause screen to run the 'yes' command with y being the output, and direct said output to the running program (rm -i).
This can be done by replacing the application file descriptors on the fly. You'll need an intermediate file though.
You can use gdb and a named pipe like this (assuming you are using more terminals, else you have to use screen or something else):
- create a named pipe with "mkfifo myYesYesPipe"
- start the interactive copy with rm -i and find its PID
- open gdb
Then type the following commands in gdb, replacing the PID
attach rmPID
call open("/path/to/myYesYesPipe",66,0666)
call dup2(3,0)
call close(3)
detach
quitThis replaces the keyboard with a named pipe for rm.
Now you have to fill the named pipe
- run yes > /path/to/myYesYesPipe
rm will read the pipe and overwrite everything.
1- Put the
rmprocess in the background withCtrl+Z. - Recall the last command (the
rm -i *command) - Remove the
-i Enterto run the commandfg %1Ctrl+C