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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If condition in Shell Script 1

Status
Not open for further replies.

annay121

Programmer
May 3, 2005
11
US
I have a situation wherein i have to check multiple conditions in an 'if' based on some variables. I have given the condition as

if [ ("${VAR1}" == "${VAR2}") || ("${VAR3}" != "${VAR4}") ]
then
.
.
else
.
.

fi

On running the script I am getting a syntax error
syntax error at line number : `(' unexpected
Addition of OR condition (||) gives me this error otherwise both the if conditions work individually.

I am using K shell


 
man ksh; man test
if [ "${VAR1}" = "${VAR2}" -o "${VAR3}" != "${VAR4}" ]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
== would work if you are using arithmetic operations in (()) .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top