Skip to content

Instantly share code, notes, and snippets.

@seventhsense
Created July 16, 2018 13:48
Show Gist options
  • Save seventhsense/a3d5b70cbea220bd0b29aa6b927fb007 to your computer and use it in GitHub Desktop.
Save seventhsense/a3d5b70cbea220bd0b29aa6b927fb007 to your computer and use it in GitHub Desktop.
add front matter for jekyll
#!/bin/bash
dir=`pwd`
list=`find ${dir} -type f`
LF=$(printf '\\\012_')
LF=${LF%_}
for file in $list; do
filename=`basename $file`
ext=${filename##*.}
if [[ $ext == "md" ]]; then
echo $filename
# for mac refer to https://markhneedham.com/blog/2011/01/14/sed-sed-1-invalid-command-code-r-on-mac-os-x/
# `sed -i "" '1i---¥nlayout: default¥n---¥n' $filename`
`sed -i "" "1s/^/---${LF}layout: default${LF}---${LF}/" $filename`
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment