Last active
August 29, 2015 13:58
-
-
Save goalsin/9936733 to your computer and use it in GitHub Desktop.
pelican下面/content/pages生成对应的html的脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function dols() | |
{ | |
echo 'Title: '$3 >$2 | |
echo 'Category:'>>$2 | |
echo 'Slug: '$4 >>$2 | |
echo ''>> $2 | |
for file in `ls -t $1` | |
do | |
if [ -d $1"/"$file ] | |
then | |
echo 'dir' | |
else | |
date_created=`echo $file| awk -F '_' '{print $1}'` | |
url=`echo $file| awk -F '_' '{print $2}'| awk -F '.' '{print $1}' ` | |
title=`head -1 $1"/"$file | awk -F ':' '{print $2}'` | |
echo "* ["$date_created" "$title"]("$url")" >> $2 | |
# echo $str | |
# echo $str >> ./out | |
fi | |
done | |
} | |
dols './content/pages/poem' './content/pages/poem.md' '诗歌' 'poem' | |
dols './content/pages/thought' './content/pages/thought.md' '随想' 'thought' |
示例
➜ blog git:(master) ✗ ./page_creator.sh
➜ blog git:(master) ✗ cat content/pages/poem_test.md
Title: 诗歌
Category:
Slug: poem
* [2013-04-17 兵马俑](bing-ma-yong)
* [2012-10-13 秋的痛](automn)
* [2012-01-17 1月16日](01-16)
* [2012-03-27 春天](spring1)
* [2012-01-13 松子](song-zi)
* [2012-01-03 预约,抑或无题](light)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
处可以写递归,但是变量要处理一下