Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ulysses!dgk From: dgk@ulysses.homer.nj.att.com (David Korn[drew]) Newsgroups: comp.unix.wizards Subject: Re: Making rm undoable Message-ID: <11388@ulysses.homer.nj.att.com> Date: 29 Mar 89 03:44:51 GMT References: <6805@phoenix.Princeton.EDU> <7360@phoenix.Princeton.EDU> <10113@bloom-beacon.MIT.EDU> Distribution: usa Organization: AT&T Bell Laboratories, Murray Hill Lines: 15 I implemented a version of unlink(name) that did a rename() to a file with the same name in a sub-directory called .trashcan, if this directory exists. I modified rm to use this unlink, and I modified rmdir to consider a directory empty if the only thing it it was a .trashcan directory. This scheme has the advantage of having the link() always on the same file system. Also, only files that have a .trashcan subdirectory are saved. Thus, you can have a single rm command that works on directories that you want files saved, and to remove trash from the .trashcan directory. Of course, I added a line to cron to clean out .trashcan directories every day.