Genii Systems wrote:

> Hi All
>
> Can anyone help me with syntax for comparing two strings in sh? Is there a
> better way I can solve this problem?
>

given a string variable str and an arbitrary shell function called myfunc which
stands in for any block of statements:

if [ "$str" = "foo" ] ; then myfunc ; fi

or

[ "$str" = "foo" ] && myfunc

or

test "$str" = "foo" && myfunc

The [ expr ] and test expr forms are exactly equivalent. The full range of
conditions that can be tested (including many tests on files) are documented in
man (1) test, though by default, bash uses a shell builtin for  functionality
similar to the test binary executable.

The only way around this is to just keep on experimenting with writing and
testing bash scripts. Eventually you'll get good! (although some would say don't

bother wasting your time, learn perl instead as it can do all that bash does and

more).

If you want to overcome your 'newbieness' quickly then may I suggest you search
UseNet on dejanews for the "The Unix FAQ". It's got some useful hints and tips
related to shell programming that will nicely complement any more traditional
documentation.

Regards

Ralph

--
[EMAIL PROTECTED]        Ralph Clark, Virgo Solutions Ltd (UK)
   __   _
  / /  (_)__  __ ____  __    * Powerful * Flexible * Compatible * Reliable *
 / /__/ / _ \/ // /\ \/ /  *Well Supported * Thousands of New Users Every Day*
/____/_/_//_/\_,_/ /_/\_\    The Cost Effective Choice - Linux Means Business!




-
To unsubscribe from this list: send the line "unsubscribe linux-diald" in
the body of a message to [EMAIL PROTECTED]

Reply via email to