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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
combining fields in two text fields shocker Shell Programming and Scripting 3 01-16-2008 08:27 AM
joining the data vakharia Mahesh UNIX Desktop for Dummies Questions & Answers 0 03-15-2007 08:49 AM
Help with joining two files rjlohman Shell Programming and Scripting 3 09-27-2006 08:55 AM
joining files Manu UNIX for Dummies Questions & Answers 2 04-25-2005 09:24 AM
joining 2 files webtekie UNIX for Dummies Questions & Answers 1 10-21-2003 07:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-26-2007
Registered User
 

Join Date: Dec 2007
Posts: 16
Joining 3 fields of a fiile

I am having two files which are pipe_delimited. I want only those rows in the output which are common values in 3 columns of both the files. The column Numbers in both the files are same as 3,29,31. Can you please suggest me a way in which i can get the required data. Thanks in advance
Reply With Quote
Forum Sponsor
  #2  
Old 12-26-2007
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 570
A sample of the input files and the wanted output would be helpful.
Reply With Quote
  #3  
Old 12-26-2007
Resident BOFH
 

Join Date: Dec 2007
Posts: 262
man join

it might take two iterations to get what you want
Reply With Quote
  #4  
Old 12-27-2007
Registered User
 

Join Date: Dec 2007
Posts: 16
Example
File 1
20071121|12|Mohit|DAV
20071222|13|Dev|MRSD
20071011|14|Rajan|ST


File 2

12|KKP|Pun|Mohit
14|FDK|Pas|Abhi
15|SAD|Hp|Lali

Now it should join based on column 2,3 of first file and 1,4 column of second file.
Now can u please help me.
Also suggest a way in which if column number are also same in both the files.
Thanks
Reply With Quote
  #5  
Old 12-27-2007
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 570
Quote:
Originally Posted by Mohit623 View Post
Example
File 1
20071121|12|Mohit|DAV
20071222|13|Dev|MRSD
20071011|14|Rajan|ST


File 2

12|KKP|Pun|Mohit
14|FDK|Pas|Abhi
15|SAD|Hp|Lali

Now it should join based on column 2,3 of first file and 1,4 column of second file.
Now can u please help me.
Also suggest a way in which if column number are also same in both the files.
Thanks
Can you also show the output you need based on the input you have provided.
Reply With Quote
  #6  
Old 12-28-2007
Registered User
 

Join Date: Dec 2007
Posts: 16
hi,
the needed result should be like this:
12|Mohit


And also tell a way in which i can get the following result:
12|Mohit|20071121|DAV|KKP|Pun

thanks
Reply With Quote
  #7  
Old 12-28-2007
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
Quote:
Originally Posted by Mohit623 View Post
hi,
the needed result should be like this:
12|Mohit
Code:
join -t\| -1 3 -2 4 -o 1.2,1.3 file1 file2
Quote:
Originally Posted by Mohit623 View Post
And also tell a way in which i can get the following result:
12|Mohit|20071121|DAV|KKP|Pun
Code:
join -t\| -1 3 -2 4  file1 file2
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0