Thursday, December 16, 2010

fixing linux's shell worst pitfal: rm

When I started working with shell few yeas ago, I remember the first thing people warned me about: the rm command has no backup. So there is no copy saved in the Recycle bin or in Trash. Many books and tutorial will share this warning, and also the wisdom that no matter how careful you are. It is bound to happen that you will delete an important file wasting the work of hours or days.

Today I thought of a solution of this for my UBUNTU 9.10. We might mention that alias doesn't work since it doesn't take arguments. Also we should make the effort to find where "Trash" is, a matter that wasn't so simple [1] [2] So the next solution is to write a function and save it in .bashrc:

function rmv () { scp $* ~/.local/share/Trash/files/; }

so now:
$rmv test.f

will put it in the trash instead of deleting it forever. If you are an extensive user of rm you should be careful not to fill up the Trash directory so maybe writing a command that will clean it say every 24 hours or few days. Maybe I will do that one day...

No comments: