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
merging CSV data using a one liner from shell? jjinca Shell Programming and Scripting 2 08-13-2007 08:15 AM
merging two lines in a file thaduka UNIX for Dummies Questions & Answers 6 07-11-2007 06:27 AM
merging two file in an ordered way raku05 Shell Programming and Scripting 2 09-22-2005 04:57 AM
Merging data ReV Shell Programming and Scripting 8 06-03-2005 12:14 AM
Merging Two File Horizontally yeheyaansari UNIX for Advanced & Expert Users 1 05-12-2003 07:30 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-10-2006
Registered User
 

Join Date: Jan 2006
Posts: 72
Need help for 2 data file merging

Hello
Please help me to write Shell script.

I want to merge 2 data files . The data files have common columns
The data file A have 3 columns

Host Version Numberof Failuers


The data file B have also 3 coulmns

Host Version NumberofFailuers .


I want to merge A and B file whereHost and version is common column in both files

The file C should contain data of A and B file


Host Version NumberofFailuers A file NumberofFailuersB File .


Before merging it should check whether Host & version of A file should be equal to Host & version of B file For eg :

For A file

Host Version NoofFailuersA
Linux 7.8 15
Sun 8.5 20
Sun 5.6 50

For B file
Host Version NoofFailuersB
Linux 7.8 15
Sun 5.6 34
Red 5.7 30


The Output File C should merge and contain data like this

Host Version NoofFailuersA NofFailuersB
Linux 7.8 15 15
Sun 8.5 20 34
Sun 5.6 50
Red 5.7 30


Please help me
Reply With Quote
Forum Sponsor
  #2  
Old 07-12-2006
Registered User
 

Join Date: Jan 2006
Posts: 72
Waiting for help . pls help me
Reply With Quote
  #3  
Old 07-12-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
You can do something like this :

Code:
awk '{print $1 "@" $2,$3}' fileA | sort -o fileA_s
awk '{print $1 "@" $2,$3}' fileB | sort -o fileB_s
join fileA_s fileB_s | awk '{sub(/@/," ",$1}' > result_file
rm fileA_s fileB_s
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 11:42 PM.


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