June 2017
Beginner
502 pages
11h 26m
English
The OR operator tests the success of two or more expressions and holds true if at least one condition is true:
#!/bin/bash echo "Hello user, please give me a number between 10 and 20 or between 50 and 10: " read user_input if [[ ${user_input} -ge 10 && ${user_input} -le 20 ]] || [[ ${user_input} -ge 50 && ${user_input} -le 100 ]]thenecho "Great! The number ${user_input} is what we were looking for!"elseecho "The number ${user_input} is not what we are looking for..."fi
What we see here are a few interesting things. First, we used a compound condition test so that we can now check between four different conditions, grouped by 2. Our test holds true if the user give us a number that is equal to or higher than 10 and at the ...
Read now
Unlock full access