为linux系统实现回收站

在linux系统中,经常采用“rm *”或“rm -r *”操作删除一下文件,但是有时某些文件并不是我们想要删除的,但是已经被删除。很多时候都是悲剧的,数据是难以恢复的,或者恢复需要花费很多的时间和精力,得不偿失。

基于上述背景,采用shell脚本为linux系统打造一个回收站。

mkdir -p /trash/

# mv removed files to trash
trash_linux()
{
    /bin/mv $@ /trash/
}

# clean all files in trash
trash_clean()
{
    /bin/rm -r /trash/*
}

# show all files in trash
trash_list()
{
    /bin/ls --color=auto /trash/
}

alias rm=trash_linux
alias clntrash=trash_clean
alias lstrash=trash_list


 

 

posted on 2013-10-28 22:24  YoungerChina  阅读(210)  评论(0编辑  收藏  举报

导航