forked from cengique/bash_basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path07-beer.sh
More file actions
24 lines (19 loc) · 660 Bytes
/
07-beer.sh
File metadata and controls
24 lines (19 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
echo "Let's sing a beer song"
echo "How many bottles?"
read count
while [ $count -ge 0 ]; do
if [ $count -ge 2 ]; then
echo "$count bottles of beer on the wall, $count bottles of beer"
echo "Take one down pass it around"
elif [ $count -eq 1 ]; then
echo "$count bottle of beer on the wall, $count bottles of beer"
echo "Take one down pass it around"
else
echo "no more bottles of beer on the wall"
fi
# the following statement is equivalent to: let "count=count-1"
((count = count - 1))
done
# exercise: implement another counting song (such as 12 days of Christmas)
# using loops and if statements.