Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Bourne Shell

Date:04/20/05
Author:Craig J. Copi
URL:n/a
Comments:0
Info:n/a
Score: (2.91 in 11 votes)
#!/bin/sh
# Bourne shell version of 99 Bottles
# Craig J Copi - copi@oddjob.uchicago.edu
#
if [ $# -eq 1 ]; then
	beers=$1
else
	beers=99
fi

s="s"

while [ $beers -gt 0 ]; do
	echo "$beers bottle$s of beer on the wall,"
	echo "$beers bottle$s of beer,"
	echo "take one down, pass it around,"
	beers=`expr $beers - 1`
	if [ $beers -ne 0 ]; then
		test $beers -eq 1 && s=""
		echo "$beers bottle$s of beer on the wall."
	else
		echo "no bottles of beer on the wall."
	fi
	echo
done

echo
echo "Time to buy some more beer . . . ."

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
small pieces loosely joinedanonymous03/14/060
Gramatically correctJeff Popp06/14/072

Comments

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!

Name:

eMail:

URL:

Security Code:
  
Comment: