One line AWK script for spliting markdown file into to multiple files. The spearator for splitting are first level markdown formatted headings.
Your markdown file is formated in the way, that heading have standard #(space) prefix. # Heading 1
.
All other heading levels 2,3,4,5,6 are not splitted.
- Open terminal
- The Mac user you need to download GAWK (becouse AWK in Mac is broken)
- Install GAWK just run command:
brew install gawk
- Paste command:
gawk -F, '/^# /{h=substr($0,3);} {print > ( h ".md")}' $Book.md$
- In script above replace
$Book.md$
with the path to markdown file you want to split. - Hit enter
- Open terminal
- Paste command:
awk -F, '/^# /{h=substr($0,3);} {print > ( h ".md")}' $Book.md$
- In script above replace
$Book.md$
with the path to markdown file you want to split. - Hit enter