Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
15 changes: 11 additions & 4 deletions generate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash

set -ex

# YOUR CODE HERE
input_dir=$1
output_dir=$2
mkdir -p "$output_dir"

for file in $input_dir/*.txt
do
title="$(head -n 1 "$file")"
body="$(tail -n +3 "$file")"
filename="$(basename "$file" .txt)".html
sed 's#{{title}}#'"$title"'#g;s#{{body}}#'"$body"'#g' template.html > "$output_dir"/"$filename"
done