Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
66 changes: 66 additions & 0 deletions 07-beer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,72 @@ done

# exercise: implement another counting song (such as 12 days of Christmas)
# using loops and if statements.
echo "Alright everyone, clear your throats—it's caroling time!"
echo "Now let's sing the 12 Days of Christmas"
echo "----------------------------------------"

for day in {1..12}; do
# Logic change: Using a case statement for ordinal suffixes (1st, 2nd, etc.)
case $day in
1) suffix="1st" ;;
2) suffix="2nd" ;;
3) suffix="3rd" ;;
*) suffix="${day}th" ;;
esac

echo "On the $suffix day of Christmas, my true love sent my way:"

# Logic change: A countdown loop to list gifts in descending order
for (( gift=day; gift>=1; gift-- )); do
case $gift in
12) echo "Twelve drummers drumming," ;;
11) echo "Eleven pipers piping," ;;
10) echo "Ten lords a-leaping," ;;
9) echo "Nine ladies dancing," ;;
8) echo "Eight maids a-milking," ;;
7) echo "Seven swans a-swimming," ;;
6) echo "Six geese a-laying," ;;
5) echo "FIVE GOLDEN RINGS!!!" ;; # Extra emphasis
4) echo "Four calling birds," ;;
3) echo "Three French hens," ;;
2) echo "Two turtle doves," ;;
1) if [ $day -eq 1 ]; then
echo "A partridge in a pear tree."
else
echo "And a partridge in a pear tree!"
fi ;;
esac
done

echo "...Next verse!" # Extra echo for pacing
echo ""
done

echo "Whew! Someone get me some eggnog."

echo "Now let's sing the 12 Days of Christmas"

day=1

while [ $day -le 12 ]; do
echo "On the $day day of Christmas, my true love gave to me"

if [ $day -ge 1 ]; then echo "a partridge in a pear tree"; fi
if [ $day -ge 2 ]; then echo "two turtle doves"; fi
if [ $day -ge 3 ]; then echo "three french hens"; fi
if [ $day -ge 4 ]; then echo "four calling birds"; fi
if [ $day -ge 5 ]; then echo "five golden rings"; fi
if [ $day -ge 6 ]; then echo "six geese a-laying"; fi
if [ $day -ge 7 ]; then echo "seven swans a-swimming"; fi
if [ $day -ge 8 ]; then echo "eight maids a-milking"; fi
if [ $day -ge 9 ]; then echo "nine ladies dancing"; fi
if [ $day -ge 10 ]; then echo "ten lords a-leaping"; fi
if [ $day -ge 11 ]; then echo "eleven pipers piping"; fi
if [ $day -ge 12 ]; then echo "twelve drummers drumming"; fi

echo ""
((day = day + 1))
done

echo "Now we sing about monkeys jumping on the bed"
echo "How many monkeys?"
Expand Down
Binary file added after-merge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions daniel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh


echo "Hello, my name is Daniel"
echo "You are happy?"
read answer

if [ "$answer" = "yes" ]; then
echo "Smile :)"
else
echo "Still Smile :)"
fi

# here are the other string comparison operators
# != , -n (not an empty string) , -z (an empty string)

# exercise: write a script that prints whether today is
# the weekend or not
echo "Which day of the week is today?"
read day

# Convert input to lowercase to make it case-insensitive
day_lower=$(echo "$day" | tr '[:upper:]' '[:lower:]')

if [[ "$day_lower" == "saturday" ]] || [[ "$day_lower" == "sunday" ]]; then
echo "Hooray!! Today is the weekend. Enjoy yourself!"
else
echo "Today is a weekday. Keep focused on your work."
fi
Binary file added two-branches.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.