fortune-cobs/mkfortunes.sh
embr a84b476ff4 I hate shell semantics sometimes
Without quoting this, the tweet:

  i;ll never be a real pig *sobs uncontrollably *

is interpreted _as if you'd typed that verbatim on the commandline_:

  i;ll never be a real pig *sobs uncontrollably dril dril.dat dril.html fortunes Makefile mkfortunes.sh README.md
2022-11-04 00:39:40 +01:00

23 lines
590 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"