View the newest xkcd comic.

2009-12-07 129 words 1 min read

This function displays the latest comic from 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 <a href="">;display $(echo "$f"|grep -Po '(?<=")[^"]+(png|jpg)');echo "$f"|awk '/<img src="" title=./{gsub(/^.title=.|".?$/,"");print}';}

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

xkcdrandom(){ local f=$(wget -q <a href=""> -O -);display $(echo "$f"|grep -Po '(?<=")[^"]+(png|jpg)');echo "$f"|awk '/<img src="" title=./{gsub(/^.title=.|".?$/,"");print}';}

  • <a href="">View this command to comment, vote or add to favourites
  • <a href="">View all commands by <a href="">eightmillion

<a href=""><img src="" alt="" align="bottom" />

by David Winterbottom (<a href="">

<a href=""><img src="" alt="" align="bottom" />
<a href=""><img src="" alt="" align="bottom" />

<img src="" alt="" width="1" height="1" align="bottom" />

URL: <a href="">


Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it