diff --git a/lib/aoc.sh b/lib/aoc.sh index f546a2b..3c84954 100755 --- a/lib/aoc.sh +++ b/lib/aoc.sh @@ -26,8 +26,11 @@ echo "Extracting example code blocks..." # extract example code blocks cat README.md | sed -n '/\[code\]/,/\[\/code\]/p' | # extract code blocks - sed '/^\s*$/d' | # remove empty lines - sed '/^\[\/code\]/d' | # remove closing bracket + sed '/\[code\]/{n;d}' | # remove (blank) lines after opening bracket + tac | # reverse line order + sed '/\[\/code\]/{n;d}' | # remove (blank) lines after closing brackets (preceding blank lines in normal order) + tac | # reverse line order again + sed '/^\[\/code\]/d' | # remove closing brackets sed 's/^ //' | # remove indentation csplit - --suppress-matched --elide-empty-files --prefix='input/example' --suffix='%d' '/\[code\]/' '{*}' echo "done."