Friday, October 12, 2007

Prevent accidental deletion of a file

Have you ever deleted a file accidentally and then repented on your action. But there is a work around that can save your life in future.

The turn around would be to declare a function in your shell called "del" as under:

del () { /bin/mv -i ${*} ~/.Trash; }
#of course you will have to create .Trash directory

as suggested by mervTormel

What it actually does is instead of deleting the file(s) it moves the file to a ~/.Trash directory. So, even if you accidentally delete a file, the file can be retried/restored again from ~/.Trash Directory.

No comments: