Read xkcd titles from the command line

Does your mobile browser have difficulty reading the ‘title’ attribute on xkcd strips? Is this a problem for you? Does your mobile device have command-line access to a unix-like system? If so, you may find the following title-extracting script useful. Call without arguments for the latest strip, or supply the strip number as an argument:

#!/bin/bash

if [ $1 ]; then
    URLPATH=$1/
fi

curl -s http://www.xkcd.com/$URLPATH |grep "img.*title" \
|sed 's/.* title="\([^"]*\).*/\1/'

One Response to “Read xkcd titles from the command line”

  1. Sailor Coruscant Says:

    That is a nifty regular expression, dude.

Leave a Reply