Customize a script based on linux instead of rm command

The rm command under linux is too powerful and cannot be undone at the same time. To avoid misuse, you can customize a script to replace the rm command. As shown below.

This script is very simple, and does not use the rm command, the function is as follows:

1. If the recycle bin does not exist, create one.

2. Delete the / at the end of the folder name (if there is /).

3, add the date to the file name or folder name, if it is a folder, first package and then put it in the recycle bin, and put the original folder under /tmp.

Save the script shown above as my_rm.sh and save it in a hidden folder, here /home/fedora/.my_remove.

Then modify the two startup scripts. Fedora is the .bashrc file in the HOME directory and /root directory. Adding a two-line command means adding this script to the environment variable and adding an alias for the rm command, as shown in the following image.

Customize a script based on linux instead of rm command

If you modify the startup script, you need to restart linux to take effect (you can use the reboot command).

If you succeed, use the alias command to see the image below.

You can use the rm command to delete something (you don't need to add the -rf option). The result is shown below (the file name and folder name are followed by a date to facilitate later search).

If you need to empty the recycle bin, you can first cd to the recycle bin, and then use the following command, so that Linux will automatically clear the /tmp directory after a while.

E-glass Rod

E-glass rod,Power fittings,Insulator fittings,Polymer insulator

TAIZHOU HUADONG INSULATED MATERIAL CO.,LTD , https://www.thim-insulator.com