Force 'rm' to run in interactive mode per directory

Oct 14, '02 09:18:35AM

Contributed by: Anonymous

Using the 'rm *' command can be dangerous, especially if you use it in a directory with '*'. If you wish to prevent the accidental deletion of one of your directores' contents, here's how. Just create an empty file called '-i' (use echo "" > -i) in the directory you wish to protect. When you subsequently use rm * in this directory, rm will prompt you to delete each file, exactly as if you had entered rm -i file1 file2 ....

[Editor's note: This is a useful trick; I've now added the -i file to a couple of my folders that I visit often in the Terminal, just in case! And if you need or want to remove the oddly named "-i" file, the easiest way is probably typing "rm ./-i".]

Comments (18)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2002101406183511