BASH on Redhat AND and OR with more than two conditions

On a Redhat Linux system running a bash shell script I need some help with an if then statement that has more than 2 conditions. I basically want to check for this
A AND B or C  
A AND B or D
A AND B or E

Something along these lines but it doesn't work and wondered if I have the correct usage of brackets. It's not what's contained for evaluation that's the issue it's the syntax of the AND and OR where there's more than two conditions that I am struggling with.

if [[ $(find /opt/app -name httptd*.conf | grep -v grep | grep -c http) -eq 0 ] && [ ! -f /etc/init.d/apache ] ||  [ $(find /app -name http*.conf | grep -v grep | grep -c http) -eq 0 ]] || \
[[ $(find /opt/app -name httptd*.conf | grep -v grep | grep -c http) -eq 0 ] && [ ! -f /etc/init.d/apache ] ||  [ $(find /application -name http*.conf | grep -v grep | grep -c http) -eq 0 ]] || \
[[ $(find /opt/app -name httptd*.conf | grep -v grep | grep -c http) -eq 0 ] && [ ! -f /etc/init.d/apache ] ||  [ $(find /application -name manifest* | grep -v grep | grep -c http) -eq 0 ]] ; then
.....
lolaferrariAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
you cannot mix [ [  ]  && etc.....
the [ is an alias for the program named test...

$( ) is different from ( )...

A AND B OR C ===
A && B || C   if you want to check programs... on exit status....  if you want to test variables use:

if [ "$var" == "$var2" -o "$var3" != "$var4" ] ; then....

in stead of $var you can use $( some command)   to get the OUTPUT of a command/
if  ( ( find /opt/app -name httptd*.conf | grep -v grep | grep -c http) && ( [  ! -f /etc/init.d/apache ] ) || ( find /app -name http*.conf | grep -v grep | grep -c http)  ) || \
 (  find /opt/app -name httptd*.conf | grep -v grep | grep -c http )  && ( [ ! -f /etc/init.d/apache ] ) ||  (find /application -name http*.conf | grep -v grep | grep -c http) - || \
(find /opt/app -name httptd*.conf | grep -v grep | grep -c http)  &&  ( [ ! -f /etc/init.d/apache ] ) ||  (find /application -name manifest* | grep -v grep | grep -c http) ) ; then ....

Open in new window


Might work better.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Also, you'll be able to write better self documenting code using PERL for this.

Keep in mind... a month or year from now when you come back to your code, be sure to write it so a simple glance will tell your or someone completely new to your code, what your code does... instantly...
0
lolaferrariAuthor Commented:
Delighted with the response!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.