Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh, test 3

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL

why the last test doesn't work? expected is true because B=b

Code:
$ A=a
$ B=b
$ C=c
$ [ $A = "a" -a $B = "b" -a $C = "c" ] && echo true || echo false
true
$ [ $A = "a" -a $B = "b" -a $C = "b" ] && echo true || echo false
false
$ [ $A = "a" -a [red][[/red] $B = "b" [red]-o[/red] $C = "b" [red]][/red] ] && echo true || echo false
ksh: b: 0403-012 A test command parameter is not valid.
false
$



 
Hi

The [tt][[/tt] is shell builtin function, you can not use it like that. The closest would be :
Code:
[ $A = "a" -a [highlight]\([/highlight] $B = "b" -o $C = "b" [highlight]\)[/highlight] ] && echo true || echo false
Tested with [tt]mksh[/tt].


Feherke.
feherke.github.io
 
To learn the correct syntax:
man test

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top