Getting my CPU usage stats up on my desktop was straight-forward enough, so I thought about what else I'd like displayed. Then I saw a forum post where someone was using curl and sed to pull out a list of items from SlashDot.
The script was this:
curl http://slashdot.org/index.rss | grep <title | sed -e ’s/<title>Slashdot</title>//g’ | sed -e ’s/<title>Search Slashdot</title>//g’ | sed -e ’s/<title>//g’ | sed -e ’s/</title>//g’Now, I wasn't interested in SlashDot, but getting the headlines from the ABC news website appealed, so I started playing with the above script, using the same idea to strip out the parts of the xml feed I didn't want.
At which point I learned something important about sed on Mac OS X - it won't wipe out blank lines. This instruction - sed -e '/^*/d' - should delete all blank lines; at least, that's what every sed tutorial tells me. But it just doesn't work on OS X. I even made sure that I had the GNU version installed rather than the POSIX one, but to no avail. So my output contained multiple blank lines between titles. Blech!
After scouring the web for hours trying to find an answer to this problem, it seemed that GeekTool had left me feeling rather un-geek-like, but certainly a bit of a tool.
I finally found part of the solution, in another forum - use perl instead of sed:
perl -pe 's/\r\n/ /'This did the job of removing the newlines, but left me with a long chain of sed and perl calls piped together, at which point I began thinking again and asked the obvious question: can I do this more simply with a single call to perl? A little more searching, and...
curl http://www.abc.net.au/news/indexes/justin/rss.xml | perl -nle 'print for m:<title>(.*)</title>:'Done.
I'm now thinking that it would be nice to be able to put somewhere on my desktop a list showing the subjects and senders of my most recent unread emails. If I can work out where and how Thunderbird keeps this info, it should be easy (note the unwarranted optimism), but it could also mean that I need to learn perl (properly). Now if only some kind person would comment on this post and provide me with a solution. (There's that unwarranted optimism again.1)
1. With apologies to Dilbert