Skip to content

Instantly share code, notes, and snippets.

@gin135 gin135/q8.sh
Last active Apr 23, 2017

Embed
What would you like to do?
第28回シェル芸勉強会 Q8の解答
cat contents.tex | # 元ファイルの出力
grep -E '^\\(|sub|subsub)section{' | # section, subsection, subsubsectionレコードの抽出
sed 's/\\label.*//' | # labelマクロの除去
sed 's/}$//' | # *sectionマクロ終了文字の除去
sed 's/{/<FS>/' | # *sectionマクロ開始文字をフィールドスペースに変換
awk -F'<FS>' '
/\\sec/{s++; ss=0; print s,$2}
/\\subsec/{ss++; sss=0; print s"."ss,$2}
/\\subsub/{sss++; print s"."ss"."sss, $2}
' # 出力の整形
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.