Unix/Linux

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • if and/or Conditional statement

    2 answers - 416 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Can someone please verify what this means?
    if [ "$1" = "offlinebackup" -o "$1" = "onlinebackup" ]; then
    I am thinking it means that if the first argument passed is equal to
    "offlinebackup" R "onlinebackup" then do the following.
    I can't seem to find any information about the "-o" anywhere.
    A confirmation and reference would be very helpful. Thanks in advance.
  • No.1 | | 571 bytes | |

    hobbzilla wrote:
    Can someone please verify what this means?

    if [ "$1" = "offlinebackup" -o "$1" = "onlinebackup" ]; then

    I am thinking it means that if the first argument passed is equal to
    "offlinebackup" R "onlinebackup" then do the following.

    I can't seem to find any information about the "-o" anywhere.

    A confirmation and reference would be very helpful. Thanks in advance.

    Yes. See the manual page of test (man test)

    EXPRESSIN1 -o EXPRESSIN2
    either EXPRESSIN1 or EXPRESSIN2 is true

    Janis
  • No.2 | | 1180 bytes | |

    10 Mar 2006 12:46:31 -0800, "hobbzilla" <hobbzilla@hotmail.comwrote:

    >Can someone please verify what this means?
    >
    >if [ "$1" = "offlinebackup" -o "$1" = "onlinebackup" ]; then
    >
    >I am thinking it means that if the first argument passed is equal to
    >"offlinebackup" R "onlinebackup" then do the following.
    >
    >I can't seem to find any information about the "-o" anywhere.


    Try;

    [ "$1" = "offlinebackup" ] || [ "$1" = "onlinebackup" ]

    I believe this is actually prefered form, according to PSIX.
    There are problems with the complicated precedence rules of 'test'
    (mixing up operators with operands) but it becomes a rats nest
    after more than about 4 arguments. You never need to use -o or -a
    with this form and it saves a lot of problems.

    >
    >A confirmation and reference would be very helpful. Thanks in advance.
    >


    Try PSIX IEEE Std 1003.1, shell & utilities - "test", I don't have a URL but a search
    with find it. Also a very good one is the freebsd man pages at;

    byefornow
    laura

Re: if and/or Conditional statement


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "Unix/Linux"

EMSDN.COM