Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A shell function to make 'rm' move files to the trash' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A shell function to make 'rm' move files to the trash
Authored by: mbenchoff on Feb 29, '08 08:58:57AM
Or you could use mv ~/.Trash filename and not have to modify anything.

[ Reply to This | # ]
A shell function to make 'rm' move files to the trash
Authored by: mbenchoff on Feb 29, '08 09:01:10AM
Whoops! Make that mv filename ~/.Trash

[ Reply to This | # ]
That's what this does
Authored by: SeanAhern on Feb 29, '08 09:16:44AM

Did you read the script? That's basically what this function does. The last statement does the mv to the Trash.

But it does a couple more things to make things easy. If you have a collision, there's something already in the Trash with the same name, it appends a timestamp. Also, it strips out any options you might have passed to what you thought was rm.

(The only other thing I'd add would be a "touch" loop, since I have a cron job that automatically deletes things in the Trash that have been in there more than a month or so. I never have to think about emptying the Trash. But I need to "touch" files I move to the Trash so that they don't get deleted at the wrong time.)



[ Reply to This | # ]
That's what this does
Authored by: leamanc on Feb 29, '08 05:54:27PM

He read the script, but is asking why use a script or function to replace a standard command when you can just type a little bit extra?



[ Reply to This | # ]