Currently, most of the Linux file systems are in Ext3 format. Once a file is deleted, it may not be restored, even if it can be recovered. Therefore, executing the rm command becomes abnormal. Therefore, we can write two Shell scripts to safely delete and restore files. The principle is very simple. Create a hidden folder ". temp" under the current user's home directory, which is equivalent to the recycle bin in Windows. To safely delete a file, cut the file to be deleted to this directory. If you want to recover, cut the files in the ". temp" directory to the original location. The Shell script for deleting files is named erase. The Code is as follows :#! /Bin/bash RecycleBin = ~ /. Temp ($ # = 0) & {echo "No paraments! "; Exit 1;} if [! -D $ RecycleBin]; then mkdir $ RecycleBin fi for I in $ * do if test-e $ I then cd $ (dirname $ I) mv-f $ (basename $ I) $ RecycleBin/$ (find $ (pwd)-maxdepth 1-name $ (basename $ I) | tr "/" "=") cd-else echo "$ I: no such file or directory! "The Shell script of the fi done recovery file is named unerase. The Code is as follows :#! /Bin/bash cd ~ /. Temp list = $ (for I in $ *; do ls | grep "<$ I>"; done) ($ # = 0 )) & {list = $ (ls | grep "") ;}for j in $ list do file =$ (echo $ j | tr "= ""/") mv $ j $ {file %/*}/$ {file # */} done saves the two files and uses the chmod command to add executable permissions to them, copy the file to the "/usr/bin" directory. Then we can use the erase and unerase commands just like using the rm command. Demonstrate how to delete the test file, restore the test file, and /. Temp "directory file changes. To safely delete certain files, use the eares command to keep up with the files to be deleted. This command supports both relative paths and absolute paths. To safely restore some files, use the unerase command to keep up with the file name to be restored. If the file name is not followed, the default restore will be "~ /. Temp "directory.