Combining <tt>test</tt>: Expressions



next up previous contents
Next: Control Structures Up: test: Comparisons Previous: Comparing Strings

Combining test: Expressions

Two or more test expressions may be combined, using the -o (or) and/or the -a (and) attributes:

    #!/bin/sh
    if test $# -eq 0
    then
        echo Must provide parameters.
        exit 1
    fi

    if test $# -gt 2 -a $# -lt 5
    then
        echo There are 3 or 4 parameters.
    fi

    if test $# -ge 1 -a $# -lt 3 
    then
        echo There are 1 or 2 parameters.
    fi
    exit 0

Note that -a has precedence over -o.



Super-User
Fri Feb 17 15:55:40 EST 1995