添加回收站,原理是:把rm 改成mv
脚本展示
1、rmtomv.sh内容
$ cat rmtomv.sh #!/bin/bashmkdir -p ~/.trashcat rmtomv.txt >> ~/.bashrcsource ~/.bashrc
2、rmtomv.txt内容
$ cat rmtomv.txtalias rm='rm -i'alias cp='cp -i'alias mv='mv -i'# Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrc fialias rm=trash alias r=trash alias rl='ls ~/.trash'alias ur=undelfile undelfile(){ mv -i ~/.trash/$@ ./}
trash(){ mv $@ ~/.trash/}cleartrash(){ read -p "clear sure?[n]" confirm [ $confirm == 'y' ] || [ $confirm == 'Y' ] && /usr/bin/rm -rf ~/.trash/*}
3、使用方法
sh rmtomv.sh
4、添加以下命令
查看垃圾回收站命令:rl
恢复文件命令
ur filename
清空垃圾箱命令
cleartrash