I got a few requests from readers of my Newfoundland trip to give them maps so they can more easily figure out where I’ve been. Should be easy given that I recorded most of the trip using a OpenGPSTracker, but that’s a story for another time. This post is about the dying practice (not art) of shell scripting.

To add the screenshots (which I already had) to the website (which was already written) I had to write a script like this:

for F in *jpg; do echo -n '<a href="'; LONG=`echo -n $F | awk -F/ '{printf "OpenGPSTracker/screenshots/"$NF;}'`; echo -n "OpenGPSTracker/screenshots/"`basename $LONG .jpg`'.png">'; echo -n '<img src="'; echo -n $F | awk -F/ '{printf "OpenGPSTracker/screenshots/"$NF;}'; echo '"></a>'; done

Which produced output like this, which I pasted into appropriate places in the HTML file:

<a href="OpenGPSTracker/screenshots/day01-1.png"><img src="OpenGPSTracker/screenshots/day01-1.jpg"></a>
<a href="OpenGPSTracker/screenshots/day01-2.png"><img src="OpenGPSTracker/screenshots/day01-2.jpg"></a>
<a href="OpenGPSTracker/screenshots/day01-3.png"><img src="OpenGPSTracker/screenshots/day01-3.jpg"></a>
<a href="OpenGPSTracker/screenshots/day01-4.png"><img src="OpenGPSTracker/screenshots/day01-4.jpg"></a>
...

I could have done it manually, adding one image at a time in Seamonkey, but for 47 images that would have been an awful lot of clicking, probably a half an hour’s worth.

I couldn’t have written a script like that when I was a student, that’s not what bothers me. What does bother me is that I don’t know a lot of people who can write something like this on the fly, in order to save themselves the time and trouble of manual work. I know less than 5 people who would do it voluntarily, and maybe another 5 who could do it if you made them.

Yes it’s unreadable and I won’t be able to figure out how it works tomorrow, but this is not software, it’s a single-use shell script. I remembered how it works long enough to get the menial task done.

There has got to be a way to make writing, debugging, and learning shell scripting easier. A GUI of some sort.. I’ll put it on my never ending TODO list.