• if-then: if-then allows you to make decisions
  • if [ $USER == "jeremy" ]; then
    echo "Hi Jeremy"
    fi
    
  • string tests: ==
  • math tests: -eq -lt -gt -le -ge
  • [ ] is a simple test
  • [[ ]] is the extended test:
  • HOSTNAME=$(/bin/hostname)
    if [[ $USER == "jeremy" && $HOSTNAME == "wittgenstein" ]]; then
    	echo "warning, jeremy, you are working on production host wittgenstein"
    	echo "please be careful with sudo on this box"
    fi
    
  • note the fi
  • if - then - elif - fi
  • NEXT
    PREVIOUS
    Master Index