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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

matching strings from 2 different files

Status
Not open for further replies.

ng1

Technical User
Aug 22, 2007
39
0
0
US
I have 2 files. In some of the records, string 1 will match but other strings will not. I want to be able to report out the records from file 2 where string 1 matches string 1 from file 1.

Ex.

FILE 1
111
222
333
444
555

FILE 2
111 AAAA
345 DKDK
4445 45TG
444 BBB

In this example, I would want to report out line 1 and line 4 from file 2.

1111 AAAA
444 BBB
 
If you have UNIX, use the join command for this


In order to understand recursion, you must first understand recursion.
 
Yes, we are using Unix. I will check that command out. Thank you.
 
The join command did the trick. Thank you again taupirho! Here is the syntax that worked for me:
join -j1 1 FILE1 FILE2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top