Match and Merge two file

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Match and Merge two file
# 8  
Old 05-11-2017
Quote:
have read through post #1 in this thread several times and still have no idea what you are trying to do.

You have one line between your two input files that match (the line in each file that contains the text column3). And, it appears that when you find that those lines do match, you ignore that fact completely. Then you say:
Quote:
I may have non match record on column3 between file1 and file1.
Sorry If it was confusing . let me explain with scenario

Quote:
File1:

123
123
123

File 2:
34
56
37

Combined

1234
1237
# 9  
Old 05-12-2017
Quote:
Originally Posted by arunkumar_mca
Sorry If it was confusing . let me explain with scenario
You need to clarify your own purposes.

Just say us how you proceeded manually to get the third file.

Regards.
# 10  
Old 05-12-2017
Quote:
Originally Posted by arunkumar_mca
Sorry If it was confusing . let me explain with scenario
The scenario doesn't help. I see absolutely no correlation between the example you showed us in post #1 and the example you showed us in post #8.

Instead of just showing us two input files and an output file, explain in English what in your two input files are being matched, merged, sorted, joined, pasted, or whatever it is that you are doing and explain how those operations are being used to create the output that you want.

Define the terms that you use with extremely clear examples. The term merge can mean very different things depending on the context. The same applies to other terms you may be used to using.
# 11  
Old 05-12-2017
Hmm - throwing dice - mumble mumble - throwing bones - waffle waffle - consulting crystal ball - cogitate - reading coffee grounds ...
How about (applying utter fantasy)
Code:
awk '{getline TMP < FN; if (substr(TMP, 1, 1) == substr ($0, length)) print $0 substr (TMP, 2) }' FN="file2" file1
1234
1237

If you consider the complex heuristic process above, how about considering and applying Don Cragun's hints?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. $1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Shell Programming and Scripting

Display match or no match and write a text file to a directory

The below bash connects to a site, downloads a file, searches that file based of user input - could be multiple (all that seems to work). What I am not able to figure out is how to display on the screen match found or no match found" and write a file to a directory (C:\Users\cmccabe\Desktop\wget)... (4 Replies)
Discussion started by: cmccabe
4 Replies

3. Shell Programming and Scripting

Merge lines based on match

I am trying to merge two lines to one based on some matching condition. The file is as follows: Matches filter: 'request ', timestamp, <HTTPFlow request=<GET: Matches filter: 'request ', timestamp, <HTTPFlow request=<GET: Matches filter: 'request ', timestamp, <HTTPFlow ... (8 Replies)
Discussion started by: jamie_123
8 Replies

4. UNIX for Dummies Questions & Answers

Merge rows into one if first 2 columns match

Hi, I wanted to merge the content and below is input and required output info. Input: /hello,a,r /hello,a,L /hello,a,X /hi,b,v /hi,b,c O/p: /hello,a,r:L:X /hi,v,:v:c Use code tags, thanks. (6 Replies)
Discussion started by: ankitas
6 Replies

5. Shell Programming and Scripting

awk match and merge with 2 files

Dear Awk experts! I have been trying to get a one liner for a match and merge operation, but having difficulties as I'm an awk newb. I always get stuck on the match and merge with 2 files. I have 2 files as follows: File 1: field 1,field 2,field 3,field 4,field 5,field 6,field 7,field... (6 Replies)
Discussion started by: landossa
6 Replies

6. Shell Programming and Scripting

Match pattern1 in file, match pattern2, substitute value1 in line

not getting anywhere with this an xml file contains multiple clients set up with same tags, different values. I need to parse the file for client foo, and change the value of tag "64bit" from false to true. cat clients.xml <Client type"FIX"> <ClientName>foo</ClientName>... (3 Replies)
Discussion started by: jack.bauer
3 Replies

7. Shell Programming and Scripting

AWK to match and merge data from 2 files into 1.

Hello, hopefully this is an easy on for the AWK guru's out there. I'm having some trouble figuring out how to match+merge data in 2 files into 1 single report. I've got my 2 files filtered and delimited, just need to MATCH $3 in file1 to $1 in file2, then put $0 from File1 and $2+$3 from File2... (6 Replies)
Discussion started by: right_coaster
6 Replies

8. Shell Programming and Scripting

Match on first and last columns and merge

Hi Friends, I have an input file of this kind input.txt output.txt The logic is as follows, read a row, compare column1 to the next, if there is a match, compare column4. If these two match, grab the minimum of column2 and maximum of column3 and print the output with column1,... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

9. Shell Programming and Scripting

Merge two file data together based on specific pattern match

My input: File_1: 2000_t g1110.b1 abb.1 2001_t g1111.b1 abb.2 abb.2 g1112.b1 abb.3 2002_t . . File_2: 2000_t Ali england 135 abb.1 Zoe british 150 2001_t Ali england 305 g1111.b1 Lucy russia 126 (6 Replies)
Discussion started by: patrick87
6 Replies

10. Shell Programming and Scripting

How to find first match and last match in a file

Hi All, I have a below file: ================== 02:53 pravin-root 02:53 pravin-root 03:05 pravin-root 02:55 pravin1-root 02:59 pravin1-root ================== How do I find the first and last value of column 1. For example, how do I find 02:53 is the first time stamp and 03:05 is... (3 Replies)
Discussion started by: praving5
3 Replies
Login or Register to Ask a Question