Here's my python one liner:
Code:
python -c 'bo,be,ta,wa,no="bottle","of beer","Take one down and pass it around","on the wall",range(99,0,-1); print "".join([ "%s %s%s %s %s,\n%s %s%s %s.\n%s, %s %s%s %s %s.\n\n" % (num,bo,["s",""][num==1],be,wa,num,bo,["s",""][num==1],be,ta,[num-1,"no more"][num-1==0],bo,["s",""][num-1==1],be,wa) for num in no ] + ["No more %ss %s %s, no more %ss %s. Go to the store and buy some more, 99 %ss %s %s." % (bo,be,wa,bo,be,bo,be,wa)] )'
Edit: Also, a version for bash:
Code:
bo="bottle";be="of beer";ta="Take one down and pass it around";wa="on the wall";i=99;while [ "$i" != 0 ]; do printf "$i $bo`[ $i != 1 ] && echo s` $be $wa,\n$i $bo`[ $i != 1 ] && echo s` $be.\n$ta, `[ $((i-1)) != 0 ] && echo $((i-1)) || echo "no more"` $bo`[ $i != 2 ] && echo s` $be.\n\n" ;i=$((i-1));done; printf "No more ${bo}s $be $wa,\nno more ${bo}s $be.\nGo to the store and buy some more, 99 ${bo}s $be $wa.\n"
Bookmarks