Non Destructive Version of rm

John 'tms' Navarra navarra at casbah.acns.nwu.edu
Sat May 4 07:26:19 AEST 1991


In article <11283 at statware.UUCP> mcf at statware.UUCP ( Mathieu Federspiel) writes:
>
>  Following are Bourne shell scripts I implemented on our systems.
>I install the scripts in /usr/local/bin, and then give everyone an
>alias of "rm" to this script.
>  What happens is, say, you "rm testfile".  The script moves
>"testfile" to ".#testfile".  You then have a period of time to
>"unrm testfile" to get the file back.  The period of time is
>determined by the system administrator, who sets up a job to run
>periodically to remove all files with names starting with ".#".
>  For this removing process, the administrator must, of course,
>warn users not to name files as ".#".  Since this is a hidden file,
>there should be no problem.  Note that this preserves the directory
>structure of files, which makes life easier than moving everything
>to ".wastebasket".  Also note that directories will be moved, and
>special handling of directories in your removing job may be
>required.
>  Enjoy!

         I am not to sure about this one. Why would you want to make a script
 which does not allow users to name a file .# something when you can just make
 an script to put ALL removed files into a directory  /var/preserve/username
 and remove all files in that directory older than two days? Then you can tell
 users that they can get into that directory and get a copy of the file they
 just removed, -- no matter what the name of it is.             
	Also, whatever script you write that searches thru EVERYONE's dir  
 looking for files beginning with a .# would be MUCH slower than doing a 
 find -mtime on a previously specified dir like /var/preserve and then removing
 those files older than 2 days.
	Also, when you remove a file from say your home directory, is there a 
 file .#file made in your home dir? and if you are in your bin directory there
 is a .#file made there? That means of course that whatever script you write
 to remove these files has to traverse EVERY damn directory on the planet lookin for .# files!
	Also, when you say hidden, you mean from ls and not ls -las. Well I do 
 a  ls -las all the time and I wouldn't want a whole bunch of .# files looking
 me in the face when I ls my directories.

 	This is what I do:
 	 
 I have a program called rm that moves all files I remove into $HOME/tmp. Then
 I have a program called night-clean which is run from crontab that looks 
 SPECIFICALLY in $HOME/tmp and removes files older than 2 days. Night-clean 
 reports what files it removes to $HOME/adm/rmlog so I can look periodically
 at what files crontab has removed in case I forget or something. 
	Of coure, rmlog grows to a considerable size after a while so I have
 another program called skim which I run to make sure it is not too big :-)

 Note though, that this is MUCH more efficient than looking a GOD knows how
 many directories looking for .# files.


>
>--
>Mathieu Federspiel                  mcf%statware.uucp at cs.orst.edu
>Statware                            orstcs!statware!mcf
>260 SW Madison Avenue, Suite 109    503-753-5382
>Corvallis  OR  97333  USA           503-758-4666 FAX
>
-- 
>From the Lab of the MaD ScIenTiST:
      
navarra at casbah.acns.nwu.edu



More information about the Comp.unix.admin mailing list