#!/bin/bash Y=$(date +%Y) G=$((Y%19 + 1)) C=$((Y/100 +1)) X=$(((3*C)/4 - 12)) Z=$(((8*C+5)/25 - 5)) D=$(((5*Y)/4-X-10)) E=$(((11*G+50+Z-(X%30))%30)) if [ ${E} -eq 25 ] && [ ${G} -gt 11 ] || [ ${E} -eq 24 ]; then E=$((E+1)) fi N=$((44-E)) if [ ${N} -lt 21 ]; then N=$((N+30)) fi N=$((N+7-((D+N)%7))) Ostern=$(( $(date +%s -d"${Y}-03-01") + (N-1)*24*60*60 )) # $1. Sonntag nach $2 sonntag_nach() { echo $(( $(date +%s -d@$2) + 24*60*60*(7*$1 + 1 - $(date +%u -d@$(($2+24*60*60)))) )) } { curl -Ss 'https://de.wikipedia.org/wiki/Liste_der_Bachkantaten' \ | sed -n ' \#^

Liste der Kantaten#,\#^

# p ' \ | tr -d '\n' \ | sed ' s#]*>[^<>]*##g s#[^<>]*##g s#]*>##g s###g ' \ | sed ' s#<\(h2\|tr\|tbody\)#\n\0#g s##\0\n#g ' \ | grep -vxF '' \ | sed -n ' \## d \##,\## p ' \ | sed -n ' 1 d $ d \#^.*]\+\)\?>Anh\.# d s#^.*]\+\)\?>\([^<>]\+\)]\+\)\?>[^<>]*]\+\)\?>\([^<>]*\).*.*$#\2 \5# T err s/^\(\S\+\) \([0-9]\+\)\( \|$\)/\1_\2\3/ p b :err s/.*/passt nicht: "\0"/ w /dev/stderr ' \ | sed ' /^\S\+ $/d s/^\(\S\+ \).*(\([^()]\+\)).*$/\1real:\2/ t s/^\(\S\+ \)Ostern$/\11. Osterfesttag/ s/^\(\S\+ \)\(Sonntag nach \)/\11. \2/ s/^\(\S\+ \)\([0-9]\+\)\. Sonntag nach \(\S\+\)$/\1\2+ \3/ ' \ | sed ' s/ / /g / Dramma per musica$/d / Huldigungskantate$/d / Ratswechsel$/d / Trauerfeier$/d / Unbekannter Anlass$/d / Weltliche Kantate$/d ' \ | while read -r bwv plus sonntag; do if [ -z "${plus##*+}" ]; then plus="${plus%+}" else if [ -z "${sonntag}" ]; then sonntag="${plus}" else sonntag="${plus} ${sonntag}" fi plus='' fi if [ -z "${sonntag##real:*}" ]; then sonntag="${sonntag#real:}" tag="${sonntag%%. *}" sonntag="${sonntag#*. }" for monat in {01..13}; do if [ ${monat} -eq 13 ]; then >&2 printf 'unbekannter Monat "%s"\n' "${sonntag}" exit 1 fi if [ "$(date +%B -d"${Y}-${monat}-01")" = "${sonntag}" ]; then break fi done ausgabe=$( date +%s -d"${Y}-${monat}-${tag}" ) elif [ -z "${sonntag%%*. Adventsonntag}" ]; then ausgabe=$( sonntag_nach "$((${sonntag%. Adventsonntag}-4))" "$(date +%s -d"${Y}-12-24")" ) elif [ "${sonntag}" = 'Weihnachten' ]; then ausgabe=$( date +%s -d"${Y}-12-24" ) elif [ -z "${sonntag%?. Weihnachtstag}" ]; then ausgabe=$(( $(date +%s -d"${Y}-12-24") + ${sonntag%. Weihnachtstag}*24*60*60 )) elif [ "${sonntag}" = 'Neujahr' ]; then ausgabe=$( date +%s -d"${Y}-01-01" ) elif [ "${sonntag}" = 'Epiphanias' ]; then ausgabe=$( date +%s -d"${Y}-01-06" ) elif [ "${sonntag}" = 'Septuagesimae' ]; then ausgabe=$(( "${Ostern}" - 7*9*24*60*60 )) elif [ "${sonntag}" = 'Sexagesimae' ]; then ausgabe=$(( "${Ostern}" - 7*8*24*60*60 )) elif [ "${sonntag}" = 'Estomihi' ]; then ausgabe=$(( "${Ostern}" - 7*7*24*60*60 )) elif [ "${sonntag}" = 'Invocabit' ]; then ausgabe=$(( "${Ostern}" - 7*6*24*60*60 )) elif [ "${sonntag}" = 'Reminiscere' ]; then ausgabe=$(( "${Ostern}" - 7*5*24*60*60 )) elif [ "${sonntag}" = 'Oculi' ]; then ausgabe=$(( "${Ostern}" - 7*4*24*60*60 )) elif [ "${sonntag}" = 'Laetare' ]; then ausgabe=$(( "${Ostern}" - 7*3*24*60*60 )) elif [ "${sonntag}" = 'Judica' ]; then ausgabe=$(( "${Ostern}" - 7*2*24*60*60 )) elif [ "${sonntag}" = 'Palmsonntag' ]; then ausgabe=$(( "${Ostern}" - 7*24*60*60 )) elif [ -z "${sonntag%?. Osterfesttag}" ]; then ausgabe=$(( Ostern + (${sonntag%. Osterfesttag}-1)*24*60*60 )) elif [ "${sonntag}" = 'Quasimodogeniti' ]; then ausgabe=$(( "${Ostern}" + 7*24*60*60 )) elif [ "${sonntag}" = 'Misericordias Domini' ]; then ausgabe=$(( "${Ostern}" + 7*2*24*60*60 )) elif [ "${sonntag}" = 'Jubilate' ]; then ausgabe=$(( "${Ostern}" + 7*3*24*60*60 )) elif [ "${sonntag}" = 'Cantate' ]; then ausgabe=$(( "${Ostern}" + 7*4*24*60*60 )) elif [ "${sonntag}" = 'Rogate' ]; then ausgabe=$(( "${Ostern}" + 7*5*24*60*60 )) elif [ "${sonntag}" = 'Christi Himmelfahrt' ]; then ausgabe=$(( "${Ostern}" + (7*6-3)*24*60*60 )) elif [ "${sonntag}" = 'Exaudi' ]; then ausgabe=$(( "${Ostern}" + 7*6*24*60*60 )) elif [ -z "${sonntag%?. Pfingstfesttag}" ]; then ausgabe=$(( Ostern + (${sonntag%. Pfingstfesttag}-1 + 7*7)*24*60*60 )) elif [ "${sonntag}" = 'Trinitatis' ]; then ausgabe=$(( "${Ostern}" + 7*8*24*60*60 )) elif [ "${sonntag}" = 'Gratulationskantate' ] || \ [ "${sonntag}" = 'Geburtstagskantate' ]; then ausgabe=$( date +%s -d"${Y}-07-25" ) elif [ "${sonntag}" = 'Hochzeit' ] || \ [ "${sonntag}" = 'Trauung' ]; then ausgabe=$( date +%s -d"${Y}-09-15" ) else >&2 printf '%s >>%s<<\n' "${bwv}" "${sonntag}" continue fi if [ -n "${plus}" ]; then ausgabe=$( sonntag_nach "${plus}" "${ausgabe}" ) fi printf '%s %s\n' \ "${bwv}" \ "$(date +%F -d@"${ausgabe}")" done printf 'cut %s\n' "$(date +%F)" } \ | LC_ALL=C sort -k2,2 -k1,1 \ | sed ' /^cut / q ' \ | grep -v '^cut ' \ | sort -k2r,2 -k1n,1 \ | uniq -f1 --group=separate \ | sed ' /^$/ q ' \ | grep -vxF '' \ | cut -d' ' -f1 \ | tr '\n' ',' \ | sed ' s/,$/\n/ '