The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
test with two conditions (OR) chebarbudo Shell Programming and Scripting 3 11-29-2008 05:39 PM
if then statements with two conditions...? audiophile Shell Programming and Scripting 3 09-19-2008 03:42 PM
Two conditions in one if statement borobudur UNIX for Dummies Questions & Answers 5 07-28-2008 10:51 PM
How to giv two conditions in IF statement..?? RRVARMA Shell Programming and Scripting 6 04-25-2008 10:33 AM
problem with if, while, for conditions kittusri9 Shell Programming and Scripting 3 04-24-2008 10:15 AM

Closed Thread
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
  #1 (permalink)  
Old 01-14-2009
dr_sabz dr_sabz is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 31
2 or more if conditions

Hello,

I have a file as follows:

col no:1 2 3 4 5 6 7 8 9 10 11

a 4 226 226 ch:95024048-95027592, 1y224 of 3545 223 224 ident
b 53 235 235 ch:148398-148401255, 1y184 of 3187 180 186 ident

awk '{if($2==4) print $0}' test ------> is great for one condition. I want 2 conditions but cannot seem to figure out the syntax needed:

if($2==4) && if($9==223) print $0

Any help would be great
Cheers
Layla
  #2 (permalink)  
Old 01-15-2009
Gayucvns Gayucvns is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 10
Hi Layla,

Please try the below command.

awk '{if($2==4 && $9==223) print $0}' test

Thanks
  #3 (permalink)  
Old 01-15-2009
dr_sabz dr_sabz is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 31
Thankyou Gayucvns
I know != is not equal to. If I want to put an "or" condition instead of an && would you know the command?

Layla
  #4 (permalink)  
Old 01-15-2009
Gayucvns Gayucvns is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 10
Hi dr,

Instead of && use ||.

command1 && command2

This statement is read, if command1 is true (has an exit status of zero) then perform command2.

The || construct will do the opposite:

command1 || command 2


If the exit status of command1 is false (non-zero), command2 will be executed.

awk '{if($2==4 || $9==223) print $0}' test

Thanks
Closed Thread

Bookmarks

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 03:14 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