#!/usr/bin/env bash link=https://wittamore.com/articles/2025 description='Ramblings from Brittany, France' rsslink=https://wittamore.com/rss.xml feedname=/home/philip/web/rss.xml postDir=/home/philip/web/articles/2025 updated=$(date --iso-8601=ns) # Build RSS header & footer header () { echo " " > ~/feedtop echo " Bloggings - wittamore.com https://wittamore.com Ramblings from Brittany, France $updated " >> ~/feedtop } footer () { echo " " >> ~/feedbottom } # Function: Build Item add to feed item () { echo " $fullTitle$postdate $linkadd $linkadd $description " >> ~/feed } # Function: Concatenate everything combine () { header footer cat ~/feedtop ~/feed > ~/feedtb cat ~/feedtb ~/feedbottom > $feedname rm ~/feedtop ~/feed ~/feedtb ~/feedbottom } # Run through files and create rss.xml if [[ -f $feedname ]]; then rm $feedname fi touch $feedname mapfile -t postArray < <(ls -t "$postDir"/*.html) postNum=0 for posts in "${postArray[@]}"; do ((postNum+=1)) post=$posts fullTitle=$(grep -o '>.*' "$post" | sed 's/\(>\|<\/h2>\)//g') postdate=$(grep -o '>.*' "$post" | sed 's/\(>\|<\/h5>\)//g') postname=${post##*/} linkadd="$link"/"$postname" description=$(sed -n '/

.*/,/*.<\/h4>/{p;q;}' "$post" | sed -e 's/<[^>]\+>/ /g' -e 's|

||g' -e 's|

||g' -e 's|"||g') item "$post" done combine exit