using rm to move to trash

Using terminal can be quite dangerous if you do not have a clear idea of what you are doing. If deleted with rm function , the deleted file does not land in trash! The file is gone from your system itself. Same can also happen with mv. Making a back up copy of your important files is a necessary precaution , but there is no guarantee that you will do it on a regular basis.

So the best thing is to put an alias to rm to use it to remove / delete to trash bin.
Open  .bashrc file in your home folder. Write
 alias rm='mv -t /home/$USER/.local/share/Trash/files/' 
at the end  and save it.Now anything removed with rm will straightaway land in your trash bin.



From now onwards TOTALLY SAFE SCRIPTING !!

Enjoy Linux !!

No comments:

Post a Comment