Language AWK
(correct text)
| Date: | 11/03/07 |
| Author: | OsamuAoki |
| URL: | http://people.debian.org/~osamu |
| Comments: | 2 |
| Info: | n/a |
| Score: |
#!/usr/bin/awk -f
# awk version of 99 bottles of beer
# by Whitey (whitey@netcom.com) - 06/05/95
# updated to create correct text including the ending
# by Osamu Aoki (osamu@debian.org) - 20007-11-04
BEGIN {
for(i = 99; i >= 0; i--) {
print ubottle(i), "on the wall,", lbottle(i) "."
print action(i), lbottle(inext(i)), "on the wall."
print
}
}
function ubottle(n) {
return sprintf("%s bottle%s of beer", n ? n : "No more", n - 1 ? "s" : "")
}
function lbottle(n) {
return sprintf("%s bottle%s of beer", n ? n : "no more", n - 1 ? "s" : "")
}
function action(n) {
return sprintf("%s", n ? "Take one down and pass it around," : \
"Go to the store and buy some more,")
}
function inext(n) {
return n ? n - 1 : 99
}
Download Source | Write Comment
Alternative Versions
| Version | Author | Date | Comments | Rate |
|---|---|---|---|---|
| bottled version | Wilhelm Weske | 11/16/08 | 0 | |
| 2 | Arnold Robbins | 01/25/08 | 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