fortune-cobs/mkfortunes.sh
2021-09-05 12:40:44 +02:00

23 lines
588 B
Bash
Executable file

#!/usr/bin/env bash
lines=$(cat dril.html |\
# war crimes
grep "<div class='text'>" | sed -e "s%<div class='text'>\(.*\)</div>%\1%" |\
# remove links
grep -vE 'https?://' |\
# remove RTs and replies (but not inline @'s)
grep -v -e '^RT @' -e '^@' |\
# unescape html entities
sed -e 's/\&amp;/\&/g' -e 's/&lt;/</g' -e 's/&gt;/>/g'
)
total=$(echo -n "$lines" | wc -l)
at=1
while read tweet; do
echo $tweet | sed 's%<br />%\n%g'
echo " -- dril"
echo %
(( at++ ))
>&2 echo -ne "\rProcessed: $at / $total"
done <<< "$lines"