Multiple Conditions in Shell
Level 3142 keystrokes
An if/elif chain tests several conditions; && inside [[ ]] requires both to be true. age is 25 and status is "active", so it prints "Eligible user".
Shell code
# Values to test1age=252status="active"# -ge is a numeric >=; && requires both tests to be true3if [[ $age -ge 18 && $status == "active" ]]; then # Runs here: 25 >= 18 and status is "active"4 echo "Eligible user"# elif is checked only if the first condition was false5elif [[ $age -lt 18 ]]; then6 echo "Too young"# fi closes the if block7fiOutput
Eligible user
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Shell code and how often they appear.
"× 8[× 4]× 4=× 4$× 3-× 2;× 2&× 2