代码拉取完成,页面将自动刷新
rm -rf
是一个危险的操作,所以我们应该尽可能养成一个不要 rm 的习惯,而是 mv。cd $home && mkdir .trash
chmod 777 .trash
.bashrc
vim .zshrc
,在文件的最后面增加下面内容:# rm transform
function rm() {
# garbage collect
now=$(date +%s)
for s in $(ls --indicator-style=none $HOME/.trash/) ;do
dir_name=${s//_/-}
dir_time=$(date +%s -d $dir_name)
# if big than one month then delete
if [[ 0 -eq dir_time || $(($now - $dir_time)) -gt 2592000 ]] ;then
echo "Trash " $dir_name " has Gone "
/bin/rm $s -rf
fi
done
# add new folder
prefix=$(date +%Y_%m_%d)
hour=$(date +%H)
mkdir -p $HOME/.trash/$prefix/$hour
if [[ -z $1 ]] ;then
echo 'Missing Args'
return
fi
echo "Hi, Trashing" $1 "to /root/.trash"
mv $1 $HOME/.trash/$prefix/$hour
}
source ~/.zshrc
rm -rf a.txt
会出现这样的提示:Hi, Trashing -rf to /root/.trash
mv: invalid option -- 'r'
Try 'mv --help' for more information.
rm a.txt
,会事显示:Hi, Trashing a.txt to /root/.trash
/usr/bin/rm -rf ~/.trash/*
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。