Language BASH
(Bourne Again Shell)
| Date: | 04/20/05 |
| Author: | Dave Plonka |
| URL: | n/a |
| Comments: | 5 |
| Info: | n/a |
| Score: |
#!/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
I like it.
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
Why in the world would you do that rather than just:
for x in {99..1}; do ...; done
for (x=99; x>0; x++); do ...; done
Anyhow, x-- not x++. Oops.