Amit Agarwal

Linux and Photography Blog
profile

This function displays the latest comic from xkcd.com. One of the best things about xkcd is the title text when you hover over the comic, so this function also displays that after you close the comic.

$ xkcd(){ local f=$(curl -s http://xkcd.com/);display $(echo "$f"|grep -Po '(?<=")http://imgs.xkcd.com/comics/[^"]+(png|jpg)');echo "$f"|awk '/<img src="http://imgs.xkcd.com/comics/.*?" title=.*/{gsub(/^.*title=.|".*?$/,"");print}';}

To get a random xkcd comic, I also use the following:

xkcdrandom(){ local f=$(wget -q http://dynamic.xkcd.com/comic/random/ -O -);display $(echo "$f"|grep -Po '(?<=")http://imgs.xkcd.com/comics/[^"]+(png|jpg)');echo "$f"|awk '/<img src="http://imgs.xkcd.com/comics/.*?" title=.*/{gsub(/^.*title=.|".*?$/,"");print}';}

by David Winterbottom (codeinthehole.com)


URL: http://feedproxy.google.com/~r/Command-line-fu/~3/JtqAcfWoFMA/view-the-newest-xkcd-comic.

Enter Your Mail Address

View the newest xkcd comic. View the newest xkcd comic.

Facebook comments:

1 Comment »

  1. [...] View the newest xkcd comic. – Amit Agarwal [...]

RSS feed for comments on this post. TrackBack URL

Leave a comment



IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

What is 11 + 3 ?
Please leave these two fields as-is:
language
terms

© 2010 Amit Agarwal | Entries (RSS) and Comments (RSS) | Valid CSS 2.1 Valid XHTML 1.0 Transitional

Powered by Wordpress 3.0.1, design by Abel, handcrafted by Abel County Laboratories, based on Wsg Standards Wsg Standards

store

Switch to our mobile site

Page optimized by WP Minify WordPress Plugin