Last active
April 23, 2017 23:54
-
-
Save gin135/fd329151e81744d48f6e67a716dfd70c to your computer and use it in GitHub Desktop.
第28回シェル芸勉強会 Q8の解答
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
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