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
26 changes: 13 additions & 13 deletions 10-greeter.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#/bin/sh
#!/bin/sh

# function in bash

function weekend_greet
{
echo "Enjoy the weekend! ${1}!"
function weekend_greet {
echo "Enjoy the weekend, $1! Extra greeting: $2"
}

function weekday_greet
{
echo "Hope you are working hard, ${1}!"
function weekday_greet {
echo "Hope you are working hard, $1! Extra greeting: $2"
}


echo "Please enter your name"
echo "Please enter your name:"
read name

day=$(date | cut -d' ' -f1) # you can use this form instead of backticks
echo "Enter a greeting or mood:"
read greeting

day=$(date | cut -d' ' -f1)

if [ $day = "Sat" ] || [ $day = "Sun" ]; then
weekend_greet $name
if [ "$day" = "Sat" ] || [ "$day" = "Sun" ]; then
weekend_greet $name $greeting
else
weekday_greet $name
weekday_greet $name $greeting
fi

# exercise: Add a second argument to the function
Expand Down
17 changes: 17 additions & 0 deletions EyobKabeto/eyob.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

echo "Hello! My name is Eyob Kabeto."
echo "Welcome to my first bash program! What is your name?"
read name
echo "Hi, $name. Nice to see you. Let's play a game!"

echo "What is 6 + 7?"
read answer

while [[ "$answer" != "13" ]]
do
echo "Incorrect. Please guess again."
read answer
done

echo "You got the right answer! Bye bye. See you again."
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.