Skip to content

Instantly share code, notes, and snippets.

@gardart
Last active July 1, 2022 01:57
Show Gist options
  • Save gardart/e4b3e51f58a1ce94b2f7 to your computer and use it in GitHub Desktop.
Save gardart/e4b3e51f58a1ce94b2f7 to your computer and use it in GitHub Desktop.
Create multiple html files from csv file using a template
#!/bin/bash
# Create multiple html files from csv file using a template
# CSV file has the structure:
# filename href
#
INPUT=data.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read flname href
do
sed -e "s@FLNAME@${flname}@" \
-e "s@HREF@${href}@" \
template.txt > $flname.html
done < $INPUT
IFS=$OLDIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment