fortune-cobs/mkfortunes.sh

23 lines
590 B
Bash
Raw Normal View History

2021-09-05 11:40:44 +01:00
#!/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'
2021-09-05 11:40:44 +01:00
echo " -- dril"
echo %
(( at++ ))
>&2 echo -ne "\rProcessed: $at / $total"
done <<< "$lines"