LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-31-2006, 04:48 PM   #1
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Rep: Reputation: 39
Cool Probably easy to answer Bash question


The simple thing of it is, i would like to do something like the following
Code:
#!/bin/bash
#for example

A=hello
B=hi
C=hey

if [ $A != `$B || $C` ]; then
I'm trying to get the statement to test that $A is not equal to Either $B or $C
 
Old 08-31-2006, 05:01 PM   #2
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
You need to compare each variable individually, i.e.

Code:
if [[ $A != $B && $A != $C ]]; then
        ....
fi
Note the double [[, this uses a different syntax to [. If you use [, then you need to use -a instead of &&.

With bash, you might also want to double quote the $variables if it's possible they could have spaces in them.

Last edited by soggycornflake; 08-31-2006 at 05:02 PM.
 
Old 08-31-2006, 05:30 PM   #3
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
Smile

nope no spaces and thanks very much.
Luv the name by the way
Soggycornflake
excellent
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
this is a noobish easy to answer question lowpingnoob Linux - Newbie 6 06-13-2005 03:10 PM
Quick Question....Easy Answer iammike Linux - Software 2 08-22-2004 01:09 PM
Easy question to answer! Please help alpineidyll Linux - Software 7 11-16-2003 02:42 PM
iptables easy to answer question BajaNick Linux - Security 4 09-19-2003 08:22 PM
Easy question to answer BajaNick Programming 3 08-03-2003 05:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration