#15 Archiving Files As They're Removed

One of the most common problems that users have with Unix, in my experience, is that there is no way to recover a file or folder that has been accidentally removed. No Norton Unerase, no Mac OS X shareware utility, nada. Once you press RETURN after typing rm xyz, it's history.

A solution to this problem is to secretly and automatically archive files and directories to a .deleted-files archive. With some fancy footwork in a script, this can be made almost completely invisible to users.

The Code

 #!/bin/sh # newrm, a replacement for the existing rm command, provides a # rudimentary unremove capability by creating and utilizing a new # directory within the user's home directory. It can handle directories ...

Get Wicked Cool Shell Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.