if and/or Conditional statement

if and/or Conditional statement

am 10.03.2006 21:46:31 von hobbzilla

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" OR "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.

Re: if and/or Conditional statement

am 10.03.2006 22:02:26 von Janis Papanagnou

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" OR "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)...

EXPRESSION1 -o EXPRESSION2
either EXPRESSION1 or EXPRESSION2 is true


Janis

Re: if and/or Conditional statement

am 10.03.2006 22:37:48 von run_signature_script_for_my_email

On 10 Mar 2006 12:46:31 -0800, "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" OR "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 POSIX.
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 POSIX 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;

http://www.freebsd.org/cgi/man.cgi?query=test&apropos=0&sekt ion=0&manpath=SunOS+4.1.3&format=html

byefornow
laura


--
echo moc.12klat@daehriaf_arual|sed 's/\(.\)\(.\),*/\2,\1/g;h;s/,//g;/@t/q;G;D'