File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Commonly used commands with this file:
4+ # bash --version
5+ # cat eg_ifel.sh
6+ # bash eg_ifel.sh
7+
8+ age=0 # initialize a variable age to 0
9+ # Provide instruction and ask for user input
10+ echo -n ' Pleaes enter your age: '
11+ read age
12+ # Ouput to terminal
13+ printf ' You claimed to be %d years old.\n' $age
14+
15+ # Determine the range of age
16+ if [ ${age} -lt 18 ]; then
17+ echo ' You are under 18 years old.'
18+ elif [ ${age} -eq 20 ]; then
19+ echo ' You may get popcorn because you are 20.'
20+ else
21+ echo ' You may proceed.'
22+ exit 1
23+ fi
24+
25+ echo ' This line may not be executed.'
26+
27+ # -gt (greater than) >
28+ # -ge (greater or equal to) >=
29+ # lt (less than) <
30+ # -le (less than or equal to) <=
31+ # -eq (equal to) ==
32+ # -nq (not equal to) !=
You can’t perform that action at this time.
0 commit comments