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 statement with a logical OR 1

Status
Not open for further replies.

jones54

Programmer
Sep 2, 2003
23
IE

Hi I want to include a simple logical OR expression in an if statement but I cannot find the correct syntax.
I have tried pipe (i.e. |) amd -a but can't seem to get either to work.

Here is what I have:
if [test ! -f "$location/parse.txt" -a $sizeOfParse = "0"]; then

I am using #!/bin/sh

Could anyone please advise me of the correct syntax.

Many Thanks
 
You wanted this ?
if [ ! -f "$location/parse.txt" -o $sizeOfParse = "0" ]; then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

Many Thanks for that PH,

That seems to have done the trick! You wouldn't believe how long it has taken me to find out that syntax.

Would you be able to point me to any good web site which explains all of the logical operators which can be used in unix scripting?

Thanks again
 
man test

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top