Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Aug 2001 18:45:38 -0500
From:      Oscar Ricardo Silva <oscars@mail.utexas.edu>
To:        freebsd-questions@freebsd.org, Drew Tomlinson <drewt@writeme.com>
Subject:   RE: Shell Script Help - Comparing Strings
Message-ID:  <5.1.0.14.2.20010814184204.00a6e040@mail.utexas.edu>
In-Reply-To: <5CD46247635BD511B6B100A0CC3F023925A06A@ldcmsx01.lc.ca.gov>
References:  <Pine.BSF.4.33.0108141546520.29182-100000@q.closedsrc.org>

next in thread | previous in thread | raw e-mail | index | archive | help
He meant to try:

if ["$1"==""]
         then $1 = "www"
fi

The difference is that "=" sets the value of something
         ex.  x = 2    sets the value of x to 2
while "==" is for comparing values
         ex.  x set to 2 and y set to 4
                 if [ x == y] is false


Oscar


At 03:50 PM 08/14/2001 -0700, Drew Tomlinson, you wrote:
> > -----Original Message-----
> > From: Linh Pham [mailto:lplist@closedsrc.org]
> > Sent: Tuesday, August 14, 2001 3:48 PM
> > To: Drew Tomlinson
> > Cc: FreeBSD Questions (E-mail)
> > Subject: Re: Shell Script Help - Comparing Strings
> >
> >
> > On 2001-08-14, Drew Tomlinson scribbled:
> >
> > # #! /bin/sh -vx
> > #
> > # #  8/8/01
> > # #  An attempt to write script to run webalizer to generate
> > web stats for all
> > # #  virtual web sites.
> > #
> > # #  Set command line variables.  $1 = web to run.
> > #
> > # #  Set $1 to "www" if blank.
> > # echo $1
> > # if ["$1"=""]
> > #   then $1 = "www"
> > # fi
> >
> > Have you tried:
> >
> > if ["$1"==""]
> >
> > instead of just having =
>
>No I hadn't but it doesn't seem to help:
>
>if ["$1"==""]
>   then $1 == "www"
>fi
>+ [test==]
>[test==]: not found
>
>What's the difference between "=" and "=="?
>
>Thanks,
>
>Drew
>
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-questions" in the body of the message


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5.1.0.14.2.20010814184204.00a6e040>