#!/bin/sh
# version 1.2
# * added the htmlURL field for Wordpress
# * escaped XML special strings from the title field
# Written by Sameer D'Costa and released into the public domain
# http://dcostanet.net/wordpress/2005/06/13/export-safari-rss-feeds-via-opml/
cat << HEADER
Safari OPML Export
HEADER
sqlite3 ~/Library/Syndication/Database3 'select * from Sources;' | \
sed -e 's/&/\&\;/g' -e 's/\<\;/g' -e 's/>/\>\;/g' -e 's/"/\"\;/g' -e 's/\x2C/\'/g' | \
awk -F"|" '{printf "\
", $4, $2 }'
cat << FOOTER
FOOTER