首页 > 代码库 > linux shell脚本遍历文件夹把md转成html

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

  

 

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