Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,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 whomever 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 Fri, Feb 29 2008 at 8:58AM PST
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 Fri, Feb 29 2008 at 9:01AM PST
Whoops! Make that mv filename ~/.Trash

[ Reply to This | # ]
That's what this does
Authored by: SeanAhern on Fri, Feb 29 2008 at 9:16AM PST
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 Fri, Feb 29 2008 at 5:54PM PST
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 | # ]