linux 防掉坑神器之 safe_rm

为了少踩坑,直接上代码

alias rm=safe_rm
export TRASH_DIR={your_path}/.__trash
safe_rm () {
    local d t f s
    [ -z "$PS1" ] && (/bin/rm "$@"; return)
    d="${TRASH_DIR}/`date +%W`"
    t=`date +%F_%H-%M-%S`
    [ -e "$d" ] || mkdir -p "$d" || return
    for f do
        [ -e "$f" ] || continue
        s=`basename "$f"`
        /bin/mv "$f" "$d/${t}_$s" || break
    done
    echo -e "[$? $t `whoami` `pwd`]$@\n" >> "$d/00rmlog.txt"

 

一行:

alias rm=safe_rm export TRASH_DIR={your_path}/.__trash safe_rm () { local d t f s     [ -z "$PS1" ] && (/bin/rm "$@"; return) d="${TRASH_DIR}/`date +%W`" t=`date +%F_%H-%M-%S` [ -e "$d" ] || mkdir -p "$d" || return for f do [ -e "$f" ] || continue s=`basename "$f"`         /bin/mv "$f" "$d/${t}_$s" || break done echo -e "[$? $t `whoami` `pwd`]$@\n" >> "$d/00rmlog.txt" }

  

上一篇:LeetCode-802. 找到最终的安全状态


下一篇:idou老师教你学Istio05: 如何用Isito实现智能路由配置