0xDEADBEEF

RSS odkazy

RSS generátor v BASHi

10. 5. 2020 #kód #RSS

Trivial but functional RSS generator in pure BASH.

root=https://example.com/
t=`grep -Po '(?<=title>).*(?=</title>)' *html | head -n1`

echo '<?xml version="1.0" encoding="utf-8"?>'
echo '<rss version="2.0"><channel><title>'$t'</title><link>'$root'</link><description></description>'

for f in *html ; do
  grep -Po '(?<=h1>).*(?=</h1>)' $f | while read t; do
    t=`echo $t | recode utf8..html`
    echo "<item><title>$t</title><guid>$root$f</guid></item>"
  done
done

echo '</channel></rss>'
píše k47 (@kaja47, k47)