Sage to Google Reader OPML converter
September 18th, 2008
[WARNING: If you are not a nerd, please jump to the following post
]
For some reason, when exporting rss feeds from Sage, a Firefox plugin, to an OPML file it does not save the feed (i.e. the xml/rss/atom/whatever) link, but the feeds themselves, i.e. the content of the feeds.
If you have the same problem, here’s a fast-and-dirty solution.
- export your Firefox bookmarks in HTML format, in a file called, say, bookmarks.html
- using a bash shell, extract the feed lines into a file called feeds.xml doing
cat bookmarks.html | grep FEEDURL > feeds.xml
- create the following script called “scriptfeed.sh”
#!/bin/bash echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" echo "<opml version=\"1.0\">" echo "<head><title>RSS Subscriptions</title></head>" echo "<body>" while read line do temp=`echo $line | awk -F"<" {'print $3;'}` feed=`echo $temp | awk -F"\"" {'print $2;'}` url=`echo $temp | awk -F"\"" {'print $4;'}` text=`echo $temp | awk -F">" {'print $2;'}` echo "<outline text=\"$text\"" echo " title=\"$text\"" echo " type=\"rss\"" echo " xmlUrl=\"$feed\"" echo " htmlUrl=\"$url\"/>" done < feeds.xml echo "</body>" echo "</opml>" - Give the script the right to execute
chmod +x scriptfeed.sh
- Launch the script on the output file, say, exp.xml
./scriptfeed.sh > exp.xml
I know, it’s dirty and tricky, but it works
Categories: Tech | Tags: awk, bash, english, google reader, rss, sage, tech



Ok, la riga di cat e’ un po’ troppo didattica. Fa notare Leo che cosi’ si insegna a sprecare processi. Quindi, se possibile fate direttamente grep FEEDURL bookmarks.html > feeds.xml e renderete felice il vostro sicuramente simpatico sysadmin.