Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge two files from a common column

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have two files...each has a phone extension column in it...how do I merge those files and print certain columns from them...??

[sig][/sig]
 
I guess you can use the [tt]join[/tt] command, but why don't you show us some example input? [sig][/sig]
 
file 1
first name|last name|addr1|addr2|city|state|zip|ext

file 2
title|dept|location|ext

Match file 1 and file 2 on ext column.
Print out only first name, last name, title, dept.

I was looking for an example in awk.

Thx. [sig][/sig]
 
Assuming matching entries in each file for any particular extension: -

join -j1 8 -j2 4 -o 1.1 1.2 2.1 2.2 file1 file2

[sig]<p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>Top man[/sig]
 
Is that [red]|[/red] character the field separator? if so, then try [tt]join -t&quot;|&quot; -j1 8 -j2 4 ...[/tt] to tell join that's the special field sep...

I hope it works... [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top