#398193 combine: allow to compare only on a subset of the lines

Package:
moreutils
Source:
moreutils
Description:
additional Unix utilities
Submitter:
Lucas Nussbaum
Date:
2015-02-02 10:27:14 UTC
Severity:
wishlist
#398193#5
Date:
2006-11-12 11:16:45 UTC
From:
To:
Package: moreutils
Version: 0.18
Severity: wishlist

Hi,

I often have the need to do operations like that:
  Get the lines from file1, ie:
    pkg1 ver1 comment1
    pkg2 ver2 comment2
    pkg3 ver3 comment3
    pkg4 ver4 comment4
  Where the first field is not in file2, ie:
    pkg2
    pkg3

combine file1 not file2 obviously won't work, since the whole lines are
compared. It would be great if one could specify a subset of fields on
which to compare, using cut's syntax for example, so I could write:
combine -d ' ' -f 1 file1 not file2

Of course, that causes problem with duplicate hash keys, and the cases
where the rest of the lines differ between the files. I propose the
following policy:
  for and/not:
    the lines in file1 are outputted
  for or/xor:
    the line in file1 is outputted, then the line if file2 if no
    matching line in file1

Additionnally, 'not' could be managed as a special case, not 'unifying'
the lines in file1, that is:
    pkg1 ver1 comment1
    pkg1 ver11 comment11
    pkg2 ver2 comment2
    pkg2 ver22 comment22
    pkg3 ver3 comment3
    pkg3 ver33 comment33
    pkg4 ver4 comment4
    pkg4 ver44 comment44
  not
    pkg2
    pkg3
would output:
    pkg1 ver1 comment1
    pkg1 ver11 comment11
    pkg4 ver4 comment4
    pkg4 ver44 comment44

Anyway, all this stuff should probably be implemented together with some
test cases.

#398193#10
Date:
2015-02-02 10:23:07 UTC
From:
To:
This is an old wishlist item, but I think it would make the combine utility
much better.

I suggest using the same parameter names as join for specifying fields to
compare.

       -t CHAR
              use CHAR as input and output field separator

       -1 FIELD
              join on this FIELD of file 1

       -2 FIELD
              join on this FIELD of file 2