In OS X 10.5, Mail gained the ability to read RSS feeds. While this isn’t a feature I use myself—it’s actually something I recently complained about—that doesn’t mean I’m not willing to share an RSS tip or two. First, because a couple people have asked me relative to the above-linked story, here’s how to get rid of the RSS section if you don’t want to use it or see it: Control-click on each listed feed and choose Delete Feed from the contextual menu. When you delete the last feed, the RSS entry disappears from the sidebar. If, in the future, you decide you’d like to see RSS feeds in Mail again, you can use the File -> Add RSS Feeds menu item to do so.
But today’s hint is actually for those use who Mail’s RSS feature, not those who don’t. Let’s say you’ve built up a nice list of feeds over time, and you’d like to share those feeds’ URLs with a friend, or just create a list to use for backup purposes. Unfortunately, Mail itself doesn’t make this easy to do—you can Conrol-click on a feed and choose Archive Feed, then go digging in the archived file for the feed’s URL. But there’s an easier way, though it does involve Terminal.
To see a list of all your subscribed feeds, open Terminal and type this command:
pubsub—client com.apple.mail list
The output will consist of two header rows, then one row of output for each subscribed feed:
Title URL Interval Client com.apple.mail : washingtonpost.com - A Section http://www.washingtonpost.com/wp-dyn/rss/print/asection/index.xml (30 min) AppShopper.com: New Apps, Version Changes and Price Changes http://appshopper.com/feed/ (30 min) AppShopper.com: New Apps (Free) http://appshopper.com/feed/?filter=new&type=free (30 min)
If you’re fine with this format, you can just copy-and-paste it into a file—or even better, have the system do that for you automatically:
pubsub—client com.apple.mail list >~/Desktop/myrss.txt
The above command will dump the full output of the command into a file named
myrss.txt on your Desktop. For most people, this will be good enough—the file is easily editable, for instance, if you want to trim it down a bit to send to a friend. You can, however, use some additional Unix magic to do the cleanup for you, and make the command easier to use in the future. Keep reading if you’d like those details.
With some help from two additional Unix programs—
sed—it’s possible to limit the output to simply the URLs, stripping out the extra lines and characters. Here’s the command that will do the magic:
pubsub—client com.apple.mail list | cut -f3 | sed -ne '3,$p'
cut command limits the output to the third field of the output, which happens to be the field that contains the actual URLs. (Though it’s not obvious in the above output, there are Tabs separating the different columns in the output;
cut sees each Tab as a field separator.) The
sed command parses the output—basically, limiting the output to everything starting on row three and beyond, so you just see the URLs in the output. Here’s what the above command generates with my test RSS feeds:
http://www.washingtonpost.com/wp-dyn/rss/print/asection/index.xml http://appshopper.com/feed/ http://appshopper.com/feed/?filter=new&type=free
Again, you can output this directly to a text file with one final addition to the command:
pubsub—client com.apple.mail list | cut -f3 | sed -ne '3,$p'>~/Desktop/myrss.txt
While this isn’t the most convenient solution possible, it does work, and isn’t all that hard. If you’d like to make it even easier, you can add this alias to your Terminal’s
alias mailrss="pubsub—client com.apple.mail list | cut -f3 | sed -ne '3,\$p'>~/Desktop/myrss.txt"
To add the above to your user’s
.profile file, type
nano ~/.profile in Terminal. Copy and paste the above line, though you can change the
mailrss to whatever you’d like to call your new command. Save the file (press Control-X, then
Y, then Return). Open a new Terminal window, type
mailrss (or whatever you changed it to), and press Return. In short order, you’ll see the
myrss.txt file on your user’s desktop. Whenever you’d like to update the file, just run the command again.