The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
TAHI Test Suite 3.0.15 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 07-10-2008 06:50 AM
How to giv two conditions in IF statement..?? RRVARMA Shell Programming and Scripting 6 04-25-2008 09:33 AM
problem with if, while, for conditions kittusri9 Shell Programming and Scripting 3 04-24-2008 09:15 AM
TAHI Test Suite 3.0.13 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 04-06-2008 12:20 PM
Keithley Introduces Linux-Based RF Parametric Test Systems - Test and Measurement.com iBot UNIX and Linux RSS News 0 07-23-2007 10:30 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-29-2008
chebarbudo's Avatar
chebarbudo chebarbudo is offline
Registered User
  
 

Join Date: Nov 2008
Location: various
Posts: 188
Question test with two conditions (OR)

Hi there,
I'm very surprised that I can't find this myself and I'm sorry to bother you with such a stupid question. I just want to write a test with one condition or another one. I want either the first argument to be equal to 'this' or the second argument to be equal to 'that'.
Code:
~$ cat test
(( $1='this' || $2='that' )) && echo test1 says ok
(( $1=='this' || $2=='that' )) && echo test2 says ok
[[ $1='this' || $2='that' ]] && echo test3 says ok
[[ $1=='this' || $2=='that' ]] && echo test4 says ok
~$ test wrong wrong
test: line 1: ((: wrong=this || wrong=that : attempted assignment to non-variable (error token is "=that ")
test2 says ok
test3 says ok
test4 says ok
~$ test this wrong
test: line 1: ((: this=this || wrong=that : attempted assignment to non-variable (error token is "=that ")
test2 says ok
test3 says ok
test4 says ok
~$ test wrong that
test: line 1: ((: wrong=this || that=that : attempted assignment to non-variable (error token is "=that ")
test2 says ok
test3 says ok
test4 says ok
~$ test this that
test: line 1: ((: this=this || that=that : attempted assignment to non-variable (error token is "=that ")
test2 says ok
test3 says ok
test4 says ok
To sum up those tests, first construct will never work, and other constructs will always return true.
Can you help me with that, I can't believe this can be hard!
Thanks in advance
Santiago
 

Bookmarks

Tags
conditionals, logical, test

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0