Thread: if statament

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    116

    if statament

    hello!

    In my script I have to check a condition using if statement
    but I'm not sure about the syntax
    Here's what I do:

    Code:
    if [[ "$var1" == aa ]]
    but I want to include also:

    Code:
    if [[ "$var1" == aa ]] -o [[ "$var1" == bb ]]
    in order to check if var1 is equal to aa OR to bb
    but it doesn't work

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    $ a=2
    $ if [[ $a == 2 || $a == 3 ]]; then echo yes; fi
    yes
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    116
    Quote Originally Posted by Salem View Post
    $ a=2
    $ if [[ $a == 2 || $a == 3 ]]; then echo yes; fi
    yes
    thanks!

Popular pages Recent additions subscribe to a feed