Go to Google Groups Home    comp.unix.solaris
Re: use diff to get same and different rows

Peter Havens <peter.hav...@gmail.com>

On Nov 18, 4:03 pm, "ela" <e...@yantai.org> wrote:

> after man diff, it seems that I cannot generate the 2 output files simply
> from files a & b?

I'm not sure I understand what you mean, but if you want to do a
comparison without regard to where lines appear in each file (which
seems to be what you want), you could probably use the `comm` command.
For example, to get lines that are common to both files, you might try
something like:

  bash$ comm -12 <(sort a) <(sort b)
  1 1 1

...or to get lines that are not common to both files:

  bash$ comm -13 <(sort a) <(sort b); comm -23 <(sort a) <(sortb)
  1 3 9
  2 2
  1 2 3

I hope that helps.

-- Pete