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

echo "Hello! What is your name"
read Jerry Kabwende
echo "Welcome, $jerry kabwende"

# 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
19 changes: 13 additions & 6 deletions 04-life.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@

echo "What is the meaning of life?"
read meaning


if [ "$meaning" -eq 42 ]; then
echo "Yes!, That is the meaning of life!"
echo "Yes! That is the meaning of life!"
else
echo "Awww... You don't know the meaning of life"
echo "It is afternoon or evening"
fi

# here are some other arithemetic comparison operators
# here are some other arithmetic comparison operators
# -eq -ne -gt -ge -lt -le

# exercise: write a script that prints whether it is
# exercise: write a script that prints whether it is
# morning or not

echo "What hour is it? (0-23)"
read hour

if [ "$hour" -lt 12 ]; then
echo "It is morning"
else
echo "It is not morning"
fi
Binary file added git.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.