shell 回收站
echo "=======================新增回收站功能========================"
echo " rm [-r]: 删除文件,命令后文件将保留在回收站中"
echo " trl: 查看回收站"
echo " trc:清空回收站"
echo " urm $filename: 恢复删除的文件到用户根目录"
echo " 若需要使用原始rm命令,请使用: /bin/rm "
mkdir -p ~/.trash
alias rm=trash
alias r=trash
alias trl=list_trash
alias urm=undelfile
alias trc=clean_trash
list_trash()
{
tree ~/.trash/|more
count_trash
}
undelfile()
{
mv -i ~/.trash/$@ ./
}
trash()
{
mv $@ ~/.trash/
}
count_trash()
{
arr=(`du -sh .trash/`)
echo "目前回收站垃圾: "$arr
}
clean_trash()
{
echo "回收站已清空!"
/bin/rm -r ~/.trash/*
count_trash
}