Archive for the 'linux' Category

Read xkcd titles from the command line

Monday, May 11th, 2009

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/'