I want to configure
rm command. When one types
rm to delete a file, then instead of deleting it right away, the file has to be transferred to the .trash of home folder. Can someone help me ?
|show 1 more comment|
migrated from serverfault.com Nov 1 '12 at 10:26
You can use LD_PRELOAD with libtrash.
You can also create hard links to your files in ~/.trash folder. When normal files (that were previously hardlinked) gets deleted, they will remain on the disk until you delete them from the "trash".
To create a hard link:
A quick solution is to add the following function declaration to your
Just my 5 cents - use instead:
On Debian, something like 'alias rm='mv -t ~/home/.trash/ ' in ~./bash_aliases should work. However, it isn't a good practice to alias rm to mv as it might affect the other users who try to delete permanently using rm. Furthermore, if you go down the aliasing route, you might have to set up a cron job to periodically empty trash.
There're a bunch of alternatives given here - mostly 3rd party tools/scripts. Hope this helps...
Keep in mind, that it's not a good idea to actually rename or move your "rm" command. A much better practice is to
in your .bash_profile (assuming you're using bash as your default shell)
and then you can create the script
This is untested, but should work for your needs. There are a few caveats that should be addressed... but it's up to you to decide how it should be handled. i.e. what happens when you delete a file, create a new one with the same name and then delete it? and this script will not clean up your trash-can. Perhaps a cron-job once a week or some such?
This will NOT override a script that calls