【Shell教学】生成git文件列表到Markdown和HTML
Tofloor
poster avatar
海天鹰
deepin
2019-08-05 01:02
Author
本帖最后由 sonichy 于 2019-8-4 17:25 编辑

#用于git主页自动部署,限制:文件名=链接名
#git ls-files 中文显示为\321,git config core.quotepath off 解决
#if的条件括号两边必须空格,条件最后用分号;结束
#多空格变一个空格,字符串外加引号解决
#换行符\n不能识别,echo -e 解决
1.生成Markdown
line=(`git ls-files`)
A="README.md"
B="index.htm"
s="# 标题\n"
for i in "${!line[@]}";
do
        L=${line[$i]}
        if [ $L != $A ] && [ $L != $B ]; then
                   s+="[${L%.*}](你的主页/$L)  \n"
        fi
done
echo -e "$s" > "README.md"


2.生成HTML
line=(`git ls-files`)
A="README.md"
B="index.htm"
s="\n\n标题\n\nbody { background:#eeeeee; }\nh1, h2 { text-align:center; }\np { text-indent:2em; font-size:1.5em; }\na { text-decoration:none; }\n\n\n\n

标题

\n"
for i in "${!line[@]}";
do
        L=${line[$i]}
        if [ $L != $A ] && [ $L != $B ]; then
                   s+="

${L%.*}

\n"
        fi
done
s+="\n"
echo -e "$s" > "index.htm"


Reply Favorite View the author
All Replies

No replies yet