tags:

views:

50

answers:

1

I have two files, A is a subset of B. Both A and B contains strings (key-value pairs) on each line. Whereas A contains the key, B has the actual key-value pair.

How do I create a file which consists of the key-value pairs whose keys come from file A using Linux commands?

Note: The key-value pairs are tab delimited where the key is the string before the first tab.

+2  A: 
cite@antiope:/tmp$ cat > A
1
3
cite@antiope:/tmp$ cat > B
1   peter
2   frank
3   jan
cite@antiope:/tmp$ join A B
1 peter
3 jan

And yes, this works with other strings than "1", "2", "3", as long as you sort A and B beforehand.

cite