Linux dangerous rm command, replace trash

They are all painful lessons of blood and tears

I have always heard about deleting databases and running away. Someone deleted the system. I never thought that I would accidentally use rm and accidentally delete the code I wrote for a day. . .

The problem is this: when repeatedly debugging and modifying a certain piece of code, due to laziness in writing scripts , when filters, filter.cpp, filter.h, filter.cpp.bak exist in the directory and filter.cpp.bak needs to be deleted, use tab under rm. Completion When multiple identical prefixes appear, I don’t know who to complete, so rm becomes rm filter* -r. A cool song

trash-cli command line version of the trash

No need for cumbersome scripts, the command line recycle bin can solve the problem, so easy.

sudo apt-get install trash-cli

# sudo vi ~/.bashrc
alias rm='trash-put'
alias rl='trash-list'
alias rr='trash-restore'
Either write the script honestly, which can solve the symptoms but not the root cause but still avoid many problems; or don't use rm; let alone do these tedious things manually with confidence. The emergence of machines and automation is to reduce duplication of work.

Guess you like

Origin blog.csdn.net/only_a_Heroic_car/article/details/128225480