Shellscript syntax question
Jan Grant
Jan.Grant at bristol.ac.uk
Tue Jan 10 02:15:55 PST 2006
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.
More information about the freebsd-questions
mailing list