#!/bin/sh cd "$HOME/notes/" || exit 1 catenate () { printf '%%%% %s {{{\n\n' "$1" cat "$1" printf '\n%%%% }}}\n\n' } pagename=$(basename "$1" .wiki) printf '%%%% logs for: %s\n\n' "$pagename" notes-links-for --target "$pagename" \ | grep -E '/(log|diary)/' \ | sort -r \ | cut -f1 -d':' \ | while read -r entry do catenate "$entry" done