Language BASH
(Bourne Again Shell)
Date: | 04/20/05 |
Author: | Dave Plonka |
URL: | n/a |
Comments: | 5 |
Info: | n/a |
Score: | (3.00 in 55 votes) |
#!/bin/bash # Bourne Again shell version of 99 Bottles # Dave Plonka - plonka@carroll1.cc.edu typeset -i n=99 typeset bottles=bottles typeset no while [ 0 != $[ n ] ] do echo "${n?} ${bottles?} of beer on the wall," echo "${n?} ${bottles?} of beer," echo "take one down, pass it around," n=n-1 case ${n?} in 0) no=no bottles=${bottles%s}s ;; 1) bottles=${bottles%s} ;; esac echo "${no:-${n}} ${bottles?} of beer on the wall." echo done exit
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
No loop, no recursion | Frédéric Lang | 07/08/08 | 3 | |
Self Writing | Olosta | 07/18/12 | 0 | |
portable, rich of features, readable | Bastian Bittorf | 08/20/07 | 0 | |
with arrays and functions | Vittorio Cagnetta | 06/30/06 | 0 | |
Arithmetic on English words for numbers | Bill Brown | 07/31/08 | 0 | |
recursive function | Koen Noens | 12/30/07 | 0 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Marcus said on 05/19/06 09:33:36
Simple, Smart - Bash!
I like it.
David said on 04/23/08 02:22:51
here is what i did on a command line on a linux box with bash a few standard commands
for x in `seq -99 -1| sed s/-//`;do echo $x bottles of beer on the wall, $x bottles of beer, take one down, pass it around... $x bottles of beer on the wall;done
Samus Aran said on 03/09/10 03:55:52
@David:
Why in the world would you do that rather than just:
for x in {99..1}; do ...; done
Samus Aran said on 03/09/10 03:57:55
Or alternatively:
for (x=99; x>0; x++); do ...; done
Samus Aran said on 03/09/10 03:59:08
They need an edit comment feature on this site. :P Or at least a preview before posting.
Anyhow, x-- not x++. Oops.