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: 26 additions & 0 deletions 01-read_input_COPY
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# read the name of the user and print hello

echo "Hello! What is your name"
read name
echo "Welcome, $name"

# single quotes prevent the expansion of the variable
echo 'Your name was stored in $name'

# exercise: write a script that asks the user for a
# filename and create an empty file named after it

echo "$name, type in a name for a new file"
read filename
echo "Thank you. Creating a file named $filename"
touch $filename.txt
echo "File $filename created."

echo "$name, what flavor of icecream do you like, chocolate or vanilla?"
read flavor
if [ "$flavor" = "chocolate" ]; then
echo "Here is a virtual chocolate ice cream cone! <3"
else
echo "Sorry, I don't rock with vanilla. Game Over."
fi
Empty file added 01-test-file.txt
Empty file.
49 changes: 49 additions & 0 deletions 03-happy_COPY.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

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 "What day is today in the week? (Ex. Monday, Tuesday, etc.)"
read day

while true; do
echo "What day is today in the week? (Ex. Monday, Tuesday, etc.)"
read day

if [ "$day" = "Monday" ]; then
echo "Not the weekend yet :("
break
elif [ "$day" = "Tuesday" ]; then
echo "Not the weekend yet :("
break
elif [ "$day" = "Wednesday" ]; then
echo "Not the weekend yet :("
break
elif [ "$day" = "Thursday" ]; then
echo "Not the weekend yet :("
break
elif [ "$day" = "Friday" ]; then
echo "Thank God it's Friday! ^^"
break
elif [ "$day" = "Saturday" ]; then
echo "It's the weekend! Time to relax :)"
break
elif [ "$day" = "Sunday" ]; then
echo "It's the weekend! Time to relax :)"
break
else
echo "You didn't type the day in correctly... Try again :/"
fi
done
Binary file added after-merge.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added ice-cream.txt
Empty file.