Replace the first line of the file with ---
:
ls *md | xargs -n 1 sed -i '1s/^/---\n/'
Replace the first blank line with ---
:
ls *md | xargs -n 1 sed -i '0,/^$/{s/^$/---\n/}'
(In the range between 0 and the first blank line (inclusive) replace blank lines with ---
)
Convert header data:
ls *md | xargs -n 1 sed -i -e 's/\(Title: \)/\L\1/'
ls *md | xargs -n 1 sed -i -e 's/\(Date: \)/\L\1/'
ls *md | xargs -n 1 sed -i -e 's/\(Tags: \)/\L\1/'
ls *md | xargs -n 1 sed -i -e 's/\(Authors: \)/\L\1/'
ls *md | xargs -n 1 sed -i -e 's/\(Summary: \)/\L\1/'
ls *md | xargs -n 1 sed -i -e 's/\(updated: \)/\L\1/'
Delete unneeded header data:
ls *md | xargs -n 1 sed -i '/Category: .*/d'
Convert tags to a list:
ls *md | xargs -n 1 sed -i -e 's/tags:[\(\s*\)\(.*\)/tags:\1[\2]/']