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

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-10-2006
getdpg getdpg is offline
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
  #2 (permalink)  
Old 07-12-2006
getdpg getdpg is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 72
Waiting for help . pls help me
  #3 (permalink)  
Old 07-12-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,428
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
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 08:01 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