From: Moody on
On May 29, 3:27 am, pac...(a)kosh.dhis.org (Alan Curry) wrote:
> In article <a3f166f0-c478-457e-bc49-a7e560af5...(a)v29g2000prb.googlegroups..com>,
>
> Moody  <nasir.mahm...(a)gmail.com> wrote:
> >I want to extract 10th column from file1 and compare it to 2nd column
> >in file2, if that matches, I want to write that line combined in a
> >thrid file
>
> join -1 10 -2 2 file1 file2
>
> See join(1)
> --
> Alan Curry

even though I tried with
join -i
but its still not working.
From: Ben Bacarisse on
Moody <nasir.mahmood(a)gmail.com> writes:

> On May 29, 3:27 am, pac...(a)kosh.dhis.org (Alan Curry) wrote:
>> In article <a3f166f0-c478-457e-bc49-a7e560af5...(a)v29g2000prb.googlegroups.com>,
>>
>> Moody  <nasir.mahm...(a)gmail.com> wrote:
>> >I want to extract 10th column from file1 and compare it to 2nd column
>> >in file2, if that matches, I want to write that line combined in a
>> >thrid file
>>
>> join -1 10 -2 2 file1 file2
>>
>> See join(1)
>
> even though I tried with
> join -i

-i won't have any effect. What were you hoping it would do?

It was not clear from your post if join does what you want. I suspect
it does, but both the input files for join must be sorted by the
relevant column -- number 10 and number 2 before running join.

Your example did not clarify what should happen when there are
duplicated values in the key columns. For example if I have you data
slightly (if you uses a fixed-with font you'll see how I've changed
column 10 more easily):

d1: ----------col 10--------------\/
1 2 3 4 5 6 7 8 9 10 11 2 3 4 12 5 6 767
34 45 567 67 8 789 890 808 09 34 432 34 232 43 5 7 687
54 5456 8 7 33 2 4 4546 5 58 68 9 4 45 3234 233 42 34
56 56 9 12 34 7 89 44 9 58 68 77 4 58 334 231 8 1

d2: --col 2---\/
CUSTOM_VALUE 10
CUSTOM1_VALUE 34
CUSTOM1_VALUE 34
CUSTOM2_Value 58

$ join -1 10 -2 2 d1 d2
10 1 2 3 4 5 6 7 8 9 11 2 3 4 12 5 6 767 CUSTOM_VALUE
34 34 45 567 67 8 789 890 808 09 432 34 232 43 5 7 687 CUSTOM1_VALUE
34 34 45 567 67 8 789 890 808 09 432 34 232 43 5 7 687 CUSTOM1_VALUE
58 54 5456 8 7 33 2 4 4546 5 68 9 4 45 3234 233 42 34 CUSTOM2_Value
58 56 56 9 12 34 7 89 44 9 68 77 4 58 334 231 8 1 CUSTOM2_Value

Note there are now fives lines of output.

> but its still not working.

That's often the most frustrating kind of reply. At least you should
say how it is not working.

--
Ben.