The UNIX and Linux Forums  


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
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 9 06-08-2009 07:11 AM
Awk Compare File1 File2 on f2 RacerX Shell Programming and Scripting 4 10-27-2008 09:50 AM
extracting lines from a file1 which maches a pattern in file2 smriti_shridhar Shell Programming and Scripting 11 07-31-2008 01:56 AM
Awk Compare f1,f2,f3 of File1 with f1 of File2 RacerX Shell Programming and Scripting 6 11-09-2007 01:34 AM
delete lines from file2 beginning w/file1 michieka Shell Programming and Scripting 13 06-24-2003 02:42 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 12-17-2008
floripoint floripoint is offline
Registered User
  
 

Join Date: Dec 2008
Location: Netherlands
Posts: 1
Unhappy awk/sed search lines in file1 matching columns in file2

Hi All,

as you can see I'm pretty new to this board.
I'm struggling around with small script to search a few fields in another file.

Basically I have file1 looking like this:
Code:
15:38:28 sz:10001 pr:14.16
15:38:28 sz:10002 pr:18.41
15:38:29 sz:10003 pr:19.28
15:38:30 sz:10004 pr:82.46
These lines are already unique and a result from a different script.
What I want to do is:
I want to search file2 for each column of file1 and print the lines from file 2 where all 3 columns of file1 are matching.
I know it sounds easy, but for some reason I'm not sure how I should address the search to use columns. file2 has a completely different structure then file1, but also contains these values.

Here is an example line from file2:
Code:
15:38:29.503~19::1858398671105952::General::Client_ReceivedObject:Depth file : textexttext na:Text side:Textindex:0 action:Delete endtr:0 ts: exid: nrord:1 sz:10003 pr:19.28
I hope somebody can point me to the right direction.
  #2 (permalink)  
Old 12-17-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,776
Code:
awk '{ print $1 > "f1"
          print $2 > "f2"
         print $3 > "f3" } ' file1
grep -f f1 file1 | grep -f f2 | grep -f f2 > searchresult.txt
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 06: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