Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!wuarchive!zaphod.mps.ohio-state.edu!ub!boulder!agcsun!jackm From: jackm@agcsun.UUCP (Jack Morrison) Newsgroups: comp.unix.misc Subject: Protection from "rm *" (summary) Message-ID: <857@agcsun.UUCP> Date: 8 Oct 90 16:27:53 GMT Reply-To: jackm@agcsun.UUCP () Distribution: usa Organization: Ampex VSD Golden Engineering, Golden, CO Lines: 71 I seem to have stirred up a little action here with the idea of having a non-writable file "#" in each directory to catch an accidental "rm *". This gets down to personal preference, but: * I don't think falling into the habit of "rm -f" would be a problem, since I rarely *want* to say "rm *". In fact, if I'm deleting everything, I'm probably deleting the directory too, in which case I'll be up one level typing "rm -rf dirname". * I don't object to aliasing rm, just to creating a mess on the disk for the 99.9% of the time I typed what I *meant* to type. On the other hand, I don't want to alias rm to "rm -i", because it's only "rm *" that's likely to be a mistake. * I *do* have a "del" script that lists all the files I've asked to delete, and asks for one confirmation. (It's included below). I tend to use this when I want to delete a bunch of files, but want to be sure what the wild carding is going to get me. In otherwords, instead of ls and then rm . I also explicitly use "rm -i" when I *know* the wildcard is going to hit some things I don't want deleted. * My favorite reply was the idea of creating a file "-i". Pretty sneaky. One disadvantage is that if I really did mean "rm *", it's going to ask me about *everything*, instead of a single query to make sure. I suppose other commands might get confused seeing a "-i" too. (And some users seemed to be confused about how to remove the "-i" file). * Eirik Fuller suggests a subdirectory with links back to the files I don't want to delete by accident. I find that a bit too much work, and worry about keeping the subdirectory up to date as new files are created. * Jay Plett points out that some systems automatically delete files with names beginning in "#" periodically. If this is the case, another pre-alphabetic name could be used instead. I'd guess that the automatic purger would leave read-only files alone anyway, but it might not. * Frank Peters (and others) point out that tcsh, among other benefits, has a variable you can set that will ask for confirmation if you say 'rm *'. My conclusion (so far) is that the non-writable "#" is an innocent way to do what I want when using csh. Oh, here's my "del" shell script (with no guarantees): ===================================================================== : delete files with confirmation if test $# -eq 0 then echo usage: del file ... else if test $# -eq 1 then echo -n delete $* '(y)?' 1>&2 else ls $* echo -n 'delete these files (y)?' 1>&2 fi read answer if test x$answer = xn -o x$answer = xno then echo no 1>&2 else echo yes 1>&2 rm $* fi fi ===================================================================== -- "How am I typing? Call 1-303-279-1300" Jack C. Morrison Ampex Video Systems 581 Conference Place, Golden CO 80401