[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell scripting in Bash



Dale,
> 
I'm not a Linux or Debian user (yet!), but if the Bash is compatible
with the Bourne shell.....

> I have been trying to learn shell scripting using the man page for bash.
> Asside from the need for a lot of reading between the lines, there seem to
> be several errors. == is declared to be the equality operator, but = is
> the correct syntax. || is declared to be the or operator, but although:
> 
> if [ a != b ]
> 
> works fine
> 
> if [ a != b || c != d ]
> 
> fails with several errors ( ']' not found, and != command not found )

The problem you have here is in ending your "list" properly for the "if"
statement. Your trying to pass two "lists" to one program, which is not
proper in this case.

This would be better:

if [ a != b ] || [ c != d ]

> 
> I have tried to enclose the expressions in {} with the same results.
> 
> What is the correct syntax for this kind of statement?
> 
> TIA,
> 
> Dwarf
> 
Also, most people when use the following format:

if [ a != b ] || [ c != d ] ;
then
	echo "your comment here"
fi

Jim Hutchins

----------------------------------------------------------------------
       FacetCorp (formerly) Structured Software Solutions, Inc.
======================================================================
 FacetCorp              | Voice : (214) 985-9901   Fax: (214) 612-2035
 4031 W. Plano Pkwy.    | E-mail: jimh@facetcorp.com
 Plano, Texas 75093     | WWW   : http://www.facetcorp.com
 U.S.A                  | Makers of FacetTerm  (tm)
======================================================================


Reply to: