美文网首页技术开发与维护我用 LinuxLinux学习之路
Linux 命令行下解决rm误删除问题 (支持mac)

Linux 命令行下解决rm误删除问题 (支持mac)

作者: onefishum | 来源:发表于2016-11-30 13:59 被阅读54次
alias rm=trash
trash()
{ 
    files=()
    timestamp=$(date +%s)
    for file in "$@"
    do
        if [[ ${file:0:1} != "-" ]] 
        then
            files=("${files[@]}" "${file}")
        fi
    done

    mkdir -p ~/.trash/$timestamp
    echo `date -r $timestamp '+%x %X'` " $timestamp: rm $* --> mv "${files[@]}" --> source: `pwd`" >> ~/.trash/.trash.log 
    mv "${files[@]}" ~/.trash/$timestamp
}

http://51strive.com/doc/201611301306.html

相关文章

网友评论

    本文标题:Linux 命令行下解决rm误删除问题 (支持mac)

    本文链接:https://www.haomeiwen.com/subject/iwhtmttx.html