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 > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ksh pattern matching ripat Shell Programming and Scripting 5 02-10-2008 04:44 PM
pattern matching in an if-then lumix Shell Programming and Scripting 4 12-14-2007 04:25 PM
Pattern Matching op4_u Shell Programming and Scripting 10 07-18-2006 12:30 AM
Pattern matching sed leemjesse Shell Programming and Scripting 3 03-23-2005 04:06 AM
Pattern Matching danhodges99 UNIX for Dummies Questions & Answers 2 02-27-2003 03:03 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-07-2008
blue_bird blue_bird is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 2
Pattern matching

I have a file containing records;

FTEFDF CC cdscsf
GDGBFCS RR cscscs
ASCCDDF WW jkkkuykhm
NKN SS sdcscscsv

My problem is to search through the entire document and extract the pair of records that contain RR and WW in the consecutive records at the second field position. The fields are separated by a space. Plz help!!

Regards;
BB.

Last edited by blue_bird; 10-07-2008 at 12:30 PM..
  #2 (permalink)  
Old 10-07-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Code:
awk '$2 == "RR", $2 == "WW"' file
  #3 (permalink)  
Old 10-07-2008
blue_bird blue_bird is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 2
Not working.

Regards,
BB

Last edited by blue_bird; 10-08-2008 at 12:22 AM..
  #4 (permalink)  
Old 10-08-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Works here. Do you get an error message? Do you have nawk / mawk / gawk that you could try instead of plain old awk? Try this, too (assuming there are always three fields, or that false matches are otherwise unlikely).

Code:
sed '/ RR /,/ WW /!d' file
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:32 AM.


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