-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# Commonly used commands with this file: | ||
# bash --version | ||
# cat eg_ifel.sh | ||
# bash eg_ifel.sh | ||
|
||
age=0 # initialize a variable age to 0 | ||
# Provide instruction and ask for user input | ||
echo -n 'Pleaes enter your age: ' | ||
read age | ||
# Ouput to terminal | ||
printf 'You claimed to be %d years old.\n' $age | ||
|
||
# Determine the range of age | ||
if [ ${age} -lt 18 ]; then | ||
echo 'You are under 18 years old.' | ||
elif [ ${age} -eq 20 ]; then | ||
echo 'You may get popcorn because you are 20.' | ||
else | ||
echo 'You may proceed.' | ||
exit 1 | ||
fi | ||
|
||
echo 'This line may not be executed.' | ||
|
||
# -gt (greater than) > | ||
# -ge (greater or equal to) >= | ||
# lt (less than) < | ||
# -le (less than or equal to) <= | ||
# -eq (equal to) == | ||
# -nq (not equal to) != |