linux shell脚本遍历文件夹把md转成html

python下安装markdown模块
http://www.cnblogs.com/zhoujinyi/p/3157015.html


 ./test.sh /data/document

=======================================================

vi ./test.sh
#!/bin/bash
 
function show()
{
    cd $1
 
    for i in `ls`
    do
        if [ -d "$i" ]
        then
            show "$1/$i"
        else
            filename=$(basename "$1/$i")
            extension="${filename##*.}"
            filename1="${filename%.*}"
            if [ "$extension" = "md" ]
            then
                eval "python -m markdown.__main__ $1/$filename1.md > $1/$filename1.html"
            fi
        fi
    done
 
    cd ..
}
 
show $1
 
exit 0

  

 

posted @ 2016-11-03 17:45  zergling9999  阅读(933)  评论(0编辑  收藏  举报