LIMIT=5000 read_dom () { ORIGINAL_IFS=$IFS IFS=\> read -d \< ENTITY CONTENT IFS=$ORIGINAL_IFS } repair_post_dates() { local count=0 local url=https://peppe.rs/posts/ while read_dom; do ((count++)) if [ "$count" -ge "$LIMIT" ]; then exit fi if [[ $ENTITY = "link" ]] ; then local _f=${CONTENT##$url} local f="posts/${_f%%/}.md" elif [[ $ENTITY = "pubDate" ]] ; then local d=$CONTENT repair "$d" "$f" fi done } repair_art_dates() { local f d while mapfile -t -n 2 a && ((${#a[@]})); do f=${a[0]} d=${a[1]} f=${f##src=\"/} d=$(dateconv -i '%d/%m — %Y' "$d") repair "$d" "$f" done } repair() { echo "[+] repairing $2" touch -am -d "$1" "$2" } grep -B1 pubDate docs/index.xml | repair_post_dates grep -Eo \ -e 'src="/art/.*.png' \ -e '[0-9]{2}/[0-9]{2}...[0-9]{4}' \ docs/art/index.html | repair_art_dates