burim:bash:udemy:logical_or_operator_example
#! /bin/bash
 
age=60
 
# for using OR operator use ||
if [ "$age" -gt 18] || ["$age" -lt 30 ]
then
  echo "valid age"
  else
  echo "age not valid"
fi
 
#  The -o option provide
# an alternative compound condition test.
if [ "$age" -gt 18 -o "$age" -lt 30 ]
then
  echo "valid age"
  else
  echo "age not valid"
fi
 
# if [[ $condition1 || $condition2 ]]    # Also works.
if [[ "$age" -gt 18 || "$age" -lt 30 ]]
then
  echo "valid age"
  else
  echo "age not valid"
fi
burim/bash/udemy/logical_or_operator_example.txt · Last modified: 2020/05/13 12:50 by burim

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki