先贴脚本,具体有时间再说......
#!/bin/bash
DIR='/data/ly/blog/source/_posts/jianshu'
cd /data/ly/blog/data
echo "start update $1 to $DIR...\n"
if [ ! -f $1 ]; then
echo "$1 not exist!\n"
exit 1
fi
tar xf $1
mkdir -p backup
mv $1 backup/
rm -rf jianshu
tmp=${1##*/}
mv ${tmp%.*} jianshu
list() {
if test -f $1; then
if [[ ${1##*.} == 'md' ]]; then
tmp=${1##*/}
title=${tmp%.*}
tmp=${1%/*}
categories=${tmp##*/}
sed -i "1s/^/---\ntitle: $title\ncategories:\n- $categories\n---\n/" $1
echo "$categories \t $title \n"
else
rm -f $1
fi
else
for f in $1/*; do
list $f
done
fi
}
list jianshu
hexo g
网友评论