Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jan 2006 10:15:39 +0000 (GMT)
From:      Jan Grant <Jan.Grant@bristol.ac.uk>
To:        Frank Staals <frankstaals@gmx.net>
Cc:        questions@freebsd.org
Subject:   Re: Shellscript syntax question
Message-ID:  <Pine.GSO.4.62.0601101012430.4734@mail.ilrt.bris.ac.uk>
In-Reply-To: <43C2C59A.6020906@gmx.net>
References:  <43C2BE4A.4070601@gmx.net> <20060109195427.GC89638@dan.emsphone.com> <43C2C59A.6020906@gmx.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 9 Jan 2006, Frank Staals wrote:

> About the asteriks : No they weren't but for some reason Thunderbird had
> problems with the color remaining from the KATE Syntax-hilighting. Anyway:
> thanks for the solusion, but what would be the expressions for ">" "less or
> equal" and "greater or equal" ?

As others have pointed out: [ is a synonym for test(1), which uses -gt, 
-ge, -eq, -ne, -lt, -le for numeric comparisons. For string comparisons, 
it uses <, !=, =, and >.

Your original expression didn't work because "<" is also a shell 
meta-character used to indicate file redirection. To get something like 
that to work, you'd need to quote it somehow:

	if [ "$a" \< "$b" ]; then ... ; fi

or

	if [ "$a" '<' "$b" ]; then ... ; fi


-- 
jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/
Tel +44 (0)117 3317661   http://ioctl.org/jan/
I'm the dandy information superhighwayman.



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