Page archived courtesy of the Geocities Archive Project https://www.geocitiesarchive.org
Please help us spread the word by liking or sharing the Facebook link below :-)


The Twelve Days of Programmers Shell Script
George Ruban

Once I had the inexplicable urge to create a Unix shell (sh) script that prints "The Twelve Days of Christmas". So I did. Here it is, in clear-text form, and in an encoded form (ROT-13 encoding) which decodes itself as it runs, so you can mail it to people who will have to run it to find out what it does.

To run it,

  1. Go to a Unix system
  2. Save the program (a set of the lines in monospace format) as a file, called, for example program
  3. Make the file executable, by typing
    chmod +x program
  4. Execute it, simply by typing the program name,
    program

Unencoded

#!/bin/sh
# Shell script which prints The Twelve Days of Programmers
# Written by George Ruban, 12-24-97
# http://www.GeoCities.com/SiliconValley/Vista/2013 
# reproduce freely, with this notice
 
ordinal="first second third fourth fifth sixth seventh eighth ninth tenth \
    eleventh twelfth"
 
n=1
 
for gift in \
    "a shell script that prints this poem." \
    "two core dumps," \
    "three broken master makes," \
    "four fatal errors," \
    "five golden files..." \
    "six spaghetti-code subroutines," \
    "seven segmentation violations," \
    "eight unreproducible bugs," \
    "nine annoyed customers," \
    "ten terrified sales-reps," \
    "eleven exultant competitors," \
    "twelve terminated programmers,"
do
    poem="$gift N $poem"
    num=`echo $ordinal | cut -d' ' -f $n`
    echo "On the" $num "day of Christmas, my hacker gave to me N" \
        $poem | tr N '\12'
    if [ $n -eq 1 ] ; then poem="and $poem" ; fi
    sleep $n
    n=`expr $n + 1`
done

Encoded

#!/bin/sh
# Written by George Ruban, 12-24-97
# http://www.GeoCities.com/SiliconValley/Vista/2013 
# reproduce freely, with this notice

o="svefg frpbaq guveq sbhegu svsgu fvkgu friragu rvtugu avagu gragu \
    ryriragu gjrysgu" ; n=1
for g in "n furyy fpevcg gung cevagf guvf cbrz." "gjb pber qhzcf," \
    "guerr oebxra znfgre znxrf," "sbhe sngny reebef," "svir tbyqra svyrf..." \
    "fvk fcnturggv-pbqr fhoebhgvarf," "frira frtzragngvba ivbyngvbaf," \
    "rvtug haercebqhpvoyr ohtf," "avar naablrq phfgbzref," \
    "gra greevsvrq fnyrf-ercf," "ryrira rkhygnag pbzcrgvgbef," \
    "gjryir grezvangrq cebtenzzref..."
do
    p="$g N $p"
    m=`echo $o | cut -d' ' -f $n`
    echo "Oa gur $m qnl bs Xznf, zl unpxre tnir gb zr N" \
        $p | tr '[a-z]N' '[n-z][a-m]\12'
    if [ $n -eq 1 ]; then p="naq $p"; fi
    sleep $n
    n=`expr $n + 1`
done
Return to main page.
GeoCities SiliconValley This page is hosted by GeoCities which will gladly give you your own Free Home Page with up to 3 megabytes of storage space as long as you put a similar message on each HTML page. Every so often they pull some annoying tricks, like the popup advertising window which may be hanging about your screen now, and my homepage hits counter, which says I have had more visitors than the Empire State Building. But hey, it's free...
1