![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Waiting for help . pls help me
|
|
#3
|
||||
|
||||
|
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
|
||||
| Google The UNIX and Linux Forums |