Linux删除文件实现回收站功能

mkdir -p ~/.Trash
vi ~/.bashrc

# .bashrc alias rm=trash alias rl='ls ~/.Trash' alias ur=undelfile undelfile() { mv -i ~/.Trash/$@ ./ } trash() { mv $@ ~/.Trash/ } cleartrash() { read -p "Clear trash?[n]" confirm [ $confirm == 'y' ] || [ $confirm == 'Y' ] && /usr/bin/rm -rf ~/.Trash/* } # User specific aliases and functions alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi


你现在可以使用rm(删除),ur(撤销),rl(列出回收站),cleartrash(清空回收站)命令了。

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

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

#撤销abc.txt
$ur abc.txt

#撤销helloworld文件夹
$ur helloworld

#列出回收站
$rl

#清空回收站
cleartrash

  

posted @ 2020-07-24 12:49  Boks  阅读(815)  评论(0编辑  收藏  举报