UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 2nd, 2005, 08:40 AM
bint bint is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: surrey, uk
Posts: 10 bint User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 42 sec
Reputation Power: 0
Unhappy multiple ands

Hi
I'm trying to write a script with
if (varable1 = x and variable2 = y and variable3 = z)
then .....
I've tried using -a and it doesn't seem happy with this. Any help would be appreciated.

Reply With Quote
  #2  
Old March 2nd, 2005, 12:06 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,307 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 28 m 57 sec
Reputation Power: 48
Code:
#!/bin/ksh
 a=1
 b=2
 c=3
 if [ $a -eq 1 ] && [ $b -eq  2 ] && [ $c -eq 3 ]; then 
     echo "yes" 
 fi

Reply With Quote
  #3  
Old March 2nd, 2005, 02:20 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 33 m 4 sec
Reputation Power: 9
the if statement is not easy, exactly in your situation (AND you have no OR statements).
in shells the -eq¦-lt¦le.... are NUMERICAL comparison operators
in perl they are ALPHABETICAL
in shell = is ALPHANUMERICAL
in perl == is NUMERICAL

as long you dont need ARITHMETICS, i mean if(2 >3) ... [ c notation]
get rid of this using a faster tool:
Code:
case $aa$bb$cc in 123) ;; *) exit ;; esac
next code.....

there is a paper in web, i dont remember, something like 'improve
shells performance' , google for and read it.
anyway this must work (on every shell, but csh)
Code:
if [ $a -eq 1 -a $b -eq  2 -a $c -eq 3 ]; then
if [ x$a = xAA -a x$b = xBB -a x$c = xCC ]; then
__________________
working on Solaris[5-9], preferred languages french and C.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > multiple ands


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway