0

There is a file1 and another file file2, then my solution to get the union file of file1 and file2 is:

  1. step: get the intersection set file

    comm -1 -2 file1 file2 >>intersectionFile
    
  2. step: get the complement set file of file1

    comm -1 -3 file1 file2 >> file1ComplementFile
    
  3. step: get the complement set file of file2

    comm -2 -3 file1 file2 >> file2ComplementFile
    
  4. step: get the union set file equals the intersection set file PLUS file1's complement set file PLUS file2's complement set file

    cat intersectionFile file1ComplementFile file2ComplementFile >> unionFile
    

MY QUESTION IS is there a better OR easier way to get the union file of file1 and file2?

glglgl
  • 89,107
  • 13
  • 149
  • 217
gameboy90
  • 303
  • 3
  • 9

1 Answers1

1

Your manipulations are identical to just comm file1 file2 >unionFile. Can you try just that?

bobah
  • 18,364
  • 2
  • 37
  • 70
  • thx!really works!the common part was outputed in third column,but looks not good.my intent is file1+file2-intersectionFile,not content listed in three column. – gameboy90 Feb 16 '14 at 16:54