centos建立回收站

开始
首先在自己家的目录创建一个文件夹用来保存删除的文件.recycling
mkdir -p ~/.recycling
修改.bachrc文件
vim ~/.bachrc
在bachrc文件中添加下面内容

alias rm=trash        
alias rl='ls ~/.recycling'  
alias ur=undelfile  
undelfile()  
{  
  mv -i ~/.recycling/$@ ./  
}  
trash()  
{  
  mv $@ ~/.recycling/  
}
cleartrash()  
{  
    read -p "Clear trash?[n]" confirm  
    [ $confirm == 'y' ] || [ $confirm == 'Y' ]  && /usr/bin/rm -rf ~/.recycling/*  
}

添加之后使用source命令使文件生效
source ~/.bachrc
命令使用方法:

#删除一个文件夹,helloworld下面的文件均被移到回收站中
$rm helloworld

#删除一个文件
$rm abc.txt

#撤销abc.txt
$ur abc.txt

#撤销helloworld文件夹
$ur helloworld

#列出回收站
$rl

#清空回收站
cleartrash

猜你喜欢

转载自blog.51cto.com/12832314/2147124
今日推荐