LOgical operator in ifeq

Posted on 2004-08-31
Last Modified: 2013-12-26
How to use a Logical operators (AND,OR) in 'ifeq' statement?

Question by:Thilak
  • 2
LVL 20

Expert Comment

ID: 11942638
if ( test -f a && test -f b )
 echo "Both files exist"

if ( test -f a || test -f z )
  echo "One of the files exists"

Or, for numerics:

if [[ 1 -eq 1 && 2 -eq 2 ]]^Jthen^Jecho "Both the same"^Jfi

if [[ 1 -eq 1 || 2 -eq 3 ]]^Jthen^Jecho "One matches"^Jfi

LVL 48

Expert Comment

ID: 11947354
Do you mean in C source?
LVL 20

Accepted Solution

tfewster earned 100 total points
ID: 11947535
Or if it's makefile syntax you mean:

I can't see any examples there of logical operators to evaluate multiple conditions, so I guess you'd need multiple ifdef tests

Author Comment

ID: 11949163
I need it for Makefile 'ifeq' statement.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now