abspath="$(dirname $(realpath "$0"))" cd $abspath dir="blog" mkdir -p html IFS=$'\n' for file in $(ls ${dir}/*.md); do template=$(cat template.html) name=$(printf "$file" | sed -e "s/.md//" -e "s/^${dir}\///") content=$(pandoc -t html "${dir}/${name}.md") title=$(cat "${dir}/${name}.md" | grep "^#[^#]" | sed -e "s/^#[ ]*//") printf "$template" "$title" "$content" > html/${name}.html done