I’ve been hunting around for a shell script to download the XKCD archives, but pretty much everything I’ve found has either done loads of redundant downloads, required too much interaction, broken on the missing comic #404 or some other issue.

In the end I decided it would be quicker to write something myself. I normally post my shell stuff on http://www.shell-fu.org/, but this is a bit long to go there really, so incase it’s useful to anyone else, I’m posting it here:

View/download yaxkcdds.sh

To use the script, just change the directory at the top and run. You can re-run the script later on and it will fetch any new comics you’ve not already got (for example it can be run as a weekly cron job).

Any bugs, please let me know in the comments.

Quite a few of the tips that get submitted on shell-fu.org aren’t that useful if you need to remember them, but are just the thing to put in your bashrc as aliases or functions. With that in mind I decided to put together a full .bashrc using the best submissions:

View/download shell-fu.org .bashrc

Feel free to use this however you like, though I’d recommend reading through it to get some idea of what each alias/function does before you use it.

I’ve tested this on my Debian system and all worked well but if you have issues on another platform, please let me know.

Only 6 months after everyone else, I noticed Nat Friedman’s Tweetable Script Challenge, and inspired by his bubble-sort I thought I’d try for a bash quicksort in under 140 characters.

So now I present, probably the most pointless code I’ve ever written (okay, that’s definitely not true, but still ):

s=`shuf -i1-9`;q(){ l=;g=;[ $# -lt 2 ]&&echo $@||(for n in ${@:2};do [ $n -gt $1 ]&&g=”$g$n “||l=”$l$n “;done;echo `q $l` $1 `q $g`;)};q $s

(You’ll need to remove line breaks for it to (hopefully) work)

As someone kindly pointed out, “It prints out the numbers 1 to 9, er, wow!”.

I’m currently learning Python, and as I’ve always found the best way to learn a new language is to use it, I decided to write a small script to give me a menu for hosts that I commonly SSH to.

I was roughly aiming to replicate a similar setup I have at work using FMLI on Solaris. My script is nowhere near as useful as FMLI, but might be useful to anyone trying to do similar (particularly as I found a real lack of Python/Curses documentation.)

Read more…