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

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))