[news.newusers.questions] alias rm to write to trash directory

broadman@paul.rutgers.edu (Allen Broadman) (02/08/90)

Since I have no easy way of retrieving files that have been
accidentally RM'ed, I would like to have my RM command actually write
files to a directory TRASH, which I could periodically empty.

1) Is there an easy way to this?
	I'd imagine that it is a combination of ALIAS and getting
	hold of the command line arguments sent to RM.

2) Is there a way to be reminded to empty the TRASH directory upon
   logging out? Is there an analagous file to .login (.logout perhaps)?  



	
-- 
------
Allen Broadman
broadman@paul.rutgers.edu

subbarao@phoenix.Princeton.EDU (Kartik Subbarao) (02/08/90)

In article <Feb.7.21.50.05.1990.10842@paul.rutgers.edu> broadman@paul.rutgers.edu (Allen Broadman) writes:
>
>I would like to have my RM command actually write
>files to a directory TRASH, which I could periodically empty.
>
>1) Is there an easy way to this?

  Sure -- Just takes a Little Shell Script.

>2) Is there a way to be reminded to empty the TRASH directory upon
>   logging out? Is there an analagous file to .login (.logout perhaps)?  

  Yep -- You guessed it!


Here you are ---

Script that puts trash in ~/Trash  (or whatever you set it to)

!# /bin/csh -f

set trash = "~/Trash"

while ($#argv)
     mv -i $argv[1] $trash # Moves it to the Trash Directory
     shift                 # Next file
end


Also, put this in your .logout

/bin/rm ~Trash/*
echo "Trash Emptied"


And thats it!


			An Up and Coming Unix Personality
			Kartik Subbarao

iwarner@axion.bt.co.uk (Ivan Warner) (02/09/90)

In your .cshrc:

	alias rm 'mv \!* ~/trash'


	This will also pass any flags (such as -i or -f) from rm to mv.


In your .logout:

	unalias rm
	rm -i ~/trash/*

doron@cfdl.larc.nasa.gov (Doron Kishoni) (02/10/90)

In article <13698@phoenix.Princeton.EDU> subbarao@phoenix.Princeton.EDU (Kartik Subbarao) writes:
>In article <Feb.7.21.50.05.1990.10842@paul.rutgers.edu> broadman@paul.rutgers.edu (Allen Broadman) writes:
>>
>>I would like to have my RM command actually write
>>files to a directory TRASH, which I could periodically empty.
>>
>>2) Is there a way to be reminded to empty the TRASH directory upon
>>   logging out? Is there an analagous file to .login (.logout perhaps)?  
>
>
>Here you are ---
>
>Script that puts trash in ~/Trash  (or whatever you set it to)
>
>!# /bin/csh -f
>set trash = "~/Trash"
>while ($#argv)
>     mv -i $argv[1] $trash # Moves it to the Trash Directory
>     shift                 # Next file
>end
>
>Also, put this in your .logout
>
>/bin/rm ~Trash/*
>echo "Trash Emptied"
>

Nice and easy!
2 typos(?) though:
  "#!" instead of "!#" on the first line of the first script. 
  "~/Trash/*" instead of "~Trash/*" in the first line of '.logout'

bill@twwells.com (T. William Wells) (02/10/90)

In article <Feb.7.21.50.05.1990.10842@paul.rutgers.edu> broadman@paul.rutgers.edu (Allen Broadman) writes:
: Since I have no easy way of retrieving files that have been
: accidentally RM'ed, I would like to have my RM command actually write
: files to a directory TRASH, which I could periodically empty.
:
: 1) Is there an easy way to this?
:       I'd imagine that it is a combination of ALIAS and getting
:       hold of the command line arguments sent to RM.
:
: 2) Is there a way to be reminded to empty the TRASH directory upon
:    logging out? Is there an analagous file to .login (.logout perhaps)?

While there may be a Unix guru on this newsgroup who will be
willing to answer your question, the better place would be in
comp.unix.questions. If that doesn't get you satisfaction, you
could then ask in comp.unix.wizards.

I also believe that the answers you need could be found by a
close examination of the manual pages for csh, ls, and rm (if you
don't have hard copy manuals, try `man csh', etc., and see what
you get); you should read those before asking the question
anywhere. If nothing else, you may be able to express the question
in a way that gets you a better answer or be in a better position
to understand the answers you do get.

Followups have been directed to comp.unix.questions.

---
Bill                    { uunet | novavax | ankh } !twwells!bill
bill@twwells.com