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 > 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
Egrep risshanth UNIX for Dummies Questions & Answers 2 06-26-2008 07:21 AM
help on egrep arund_01 Shell Programming and Scripting 2 05-13-2008 01:26 PM
egrep help Darklight Shell Programming and Scripting 1 04-18-2008 02:34 AM
egrep DNAx86 Shell Programming and Scripting 7 01-18-2008 08:59 AM
Egrep cheat sheet anywhere? Looking for meaning of egrep -c leelm UNIX for Dummies Questions & Answers 2 01-11-2008 03:37 PM

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 07-03-2008
krao krao is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 16
Smile egrep

HI,

I want to grep the contents of fileb from filea.

filbeb
5x4xxx371x31a43
4x40x037103a049
3x4x003710a0659
4x4x0x371a50912


filbea
5x4xxx371x31a43 3266000225
4x4003266000277 3266000277
4x400326x000499 3266000499
4x4003266000676 3266000676
4x4x0x371a50912 3266000777
4x40x037103a049 3266001819
4x40xx371057013 3266001820
4x4x00371056788 3266001821
3x4x003710a0659 3266001823



output should be as shown below

3266000225
3266001819
3266001823
3266000777



I used below code but giving error as Segmentation Fault (core dumped)


egrep -f fileb filea | awk '{print $2}' >> output


fileb count is 90535
filea count is 1591132

Pls help me
  #2 (permalink)  
Old 07-03-2008
incredible incredible is offline Forum Advisor  
Registered User
  
 

Join Date: May 2008
Location: s'pore
Posts: 2,073
will something like this work?
a=`cat filbeb`

cat filbea |grep ${a} | awk '{print $2}' > /tmp/output
  #3 (permalink)  
Old 07-03-2008
krao krao is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 16
hi incredible
above is not working
  #4 (permalink)  
Old 07-03-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Code:
nawk 'FNR==NR {a[$1];next} $1 in a {print $2}' fileb filea
  #5 (permalink)  
Old 07-03-2008
krao krao is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 16
thanks vgersh99, it is working

can u plz explain , how does ur code works bcoz i am new to nawk.
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 12:09 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