为了少踩坑,直接上代码
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" }