Because the RM command deleted files will not be put into the garbage bin, so can not be restored, the following small series to introduce a method, by replacing the Linux RM command method, so that the RM command deleted files into the garbage bin.
Method:
1. Create a new directory under the/home/username/directory, named:. Trash
2. In the/home/username/tools/directory, create a new shell file named: remove.sh
para_cnt=$#
Trash_dir= "/home/username/.trash"
For i in $*; Do
stamp= ' Date +%s '
Filename= ' basename $i '
MV $i $TRASH _dir/$fileName. $STAMP
Done
3. Modify ~/.BASHRC, add a line
Alias rm= "Sh/home/username/tools/remove.sh"
Replace the RM command with our self-built remove.sh
4. Set up the crontab and empty the bins regularly, such as:
0 0 * * * rm-rf/home/username/.trash/*
Empty the trash bin at 0 o ' Day
5. Source ~/.BASHRC make the substitution take effect immediately
The above is the Linux RM command mistakenly deleted file into the garbage bin method introduced, using the method described in this article to replace the RM command, timely files are mistakenly deleted also do not worry, to the garbage bin recovery.
Transferred from: http://www.xitongzhijia.net/xtjc/20150306/40342.html
How to put files deleted by the Linux RM command into a trash bin