Code: Select all
#!/usr/bin/env bash
set -euxo pipefail
mkdir -p out/
shopt -s extglob
cp -r !(out) out/
shopt -u extglob
shopt -s globstar
for filename in **/*.html; do
if [[ ! $filename =~ "out/" ]]; then
mkdir -p "$(dirname $filename)"
cpp -traditional-cpp -P "$filename" > "out/$filename"
fi
done
shopt -u globstar
It's certainly not something I'd do for anything more complex, but it works remarkably well for what I want, which is just putting in a uniform header and footer.