Skip to content

Instantly share code, notes, and snippets.

@gin135
Last active April 23, 2017 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gin135/fd329151e81744d48f6e67a716dfd70c to your computer and use it in GitHub Desktop.
Save gin135/fd329151e81744d48f6e67a716dfd70c to your computer and use it in GitHub Desktop.
第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