Skip to content

Instantly share code, notes, and snippets.

@kurahaupo
Last active August 29, 2015 14:07
Show Gist options
  • Save kurahaupo/1abb44d79191fe46ff5e to your computer and use it in GitHub Desktop.
Save kurahaupo/1abb44d79191fe46ff5e to your computer and use it in GitHub Desktop.
twelve days of christmas, in bash
#!/path/to/your/bash
dox=( [1]='a partridge in a pair tree'
'2 turtle doves, and'
'3 french hens'
'4 calling birds'
$'5 gold rings\n ...'
'6 geese a-laying'
'7 swans a-swimming'
'8 maids a-milking'
'9 ladies dancing'
'10 lords a-leaping'
'11 pipers piping'
'12 drummers drumming')
suf=( [1]=st nd rd )
for ((i=1;i<=${#dox[@]};i++)) do
printf '\nOn the %d%s day of Christmas, my true love sent to me:\n' $i ${suf[i]:-th}
for ((j=i;j>=1;j--)) do
printf ' %s\n' "${dox[j]}"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment