Linux 命令行下解决rm误删除问题 (支持mac)
alias rm=trashtrash(){timestamp=$(date +%s)dir=`echo ' '$@ | sed 's/ --\{0,1\}[a-z]\{1,\}//g'`mkdir -p ~/.trash/$timestampecho `date -r $timestamp '+%x %X'` " $timestamp: rm $
·
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
#ls -l "${files[@]}"
mv "${files[@]}" ~/.trash/$timestamp
}
更多推荐
已为社区贡献1条内容
所有评论(0)