Linux系统默认没有回收站功能,使用rm命令进行删除操作,文件就会直接从系统中删除,很难恢复。
今天我们利用简单的shell脚本实现Linux系统下的回收站机制。
先提供脚本代码
[root@qll251 ~]# vim /bin/delete
1 #! /bin/bash
2 [ ! -d /.recycle ] && mkdir -v /.recycle && chmod 777 /.recycle
3
4 if [ $# -eq 0 ]; then
5 echo "Usage: delete file1 [file2 file3...]" && exit 6
6 fi
7
8 read -p