You can use Linux rm command with -i or -I options to prompt before deletion of a file or directory in Linux.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## You can use rm -i to prompt before every removal. touch myfile1 myfile2 ## create some files rm -i myfile* ## prompt before every removal ## rm: remove regular empty file ‘myfile1’? y ## rm: remove regular empty file ‘myfile2’? y ## You can also use rm -I option to prompt once before removing more than three files, or ## when removing recursively; less intrusive than -i, while still giving protection against most mistakes touch myfile{1..10} ## create some files rm -I myfile* ## prompt before removal if more than three files ## rm: remove 10 arguments? y mkdir -p mydir1/mydir2/mydir3/mydir4 ## create some directories rm -rI mydir1 ## prompt before removal ## rm: remove 1 argument recursively? y |