Skip to main content
Tweeted twitter.com/#!/StackUnix/status/361776283102887936
Rollback to Revision 3
Source Link
jordanm
  • 43.6k
  • 10
  • 121
  • 115

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2). Logic:

Logic:
If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1:

sc2/80 20 . A T 86 Pass N=2 F=5;U=4

sc2/60 55 . G T 76 Pass N=2 F=5;U=4

sc2/68 20 . T C 71 Pass N=2 F=5;U=4

sc2/24 24 . T G 31 Pass N=2 F=5;U=4

File2:

sc2/80 20 . A C 80 Pass N=2 F=5;U=4

sc2/60 55 . G C 72 Pass N=2 F=5;U=4

sc2/68 20 . T C 71 Pass N=2 F=5;U=4

sc2/10 24 . T G 31 Pass N=2 F=5;U=4File1:

sc2/40 59 . T G 31 Pass N=2 F=5;U=4

sc2/80         20      .        A       T         86       PASS     N=2     F=5;U=4
sc2/60         55      .        G       T         76       PASS     N=2     F=5;U=4 
sc2/68         20      .        T       C         71       PASS     N=2     F=5;U=4
sc2/24         24      .        T       G         31       PASS     N=2     F=5;U=4

sc2/24 24 . A G 38 Pass N=2 F=5;U=4File2:

OUTPUT:

sc2/80         20      .        A        C        80      PASS    N=2       F=5;U=4
sc2/60         55      .        G        C        72      PASS    N=2       F=5;U=4 
sc2/68         20      .        T        C        71      PASS    N=2       F=5;U=4 
sc2/10         24      .        T        G        31      PASS    N=2       F=5;U=4
sc2/40         59      .        T        G        31      PASS    N=2       F=5;U=4
sc2/24         24      .        A        G        38      PASS    N=2       F=5;U=4

sc2/80 20 . A T 86 Pass N=2 F=5;U=4 sc2/80 20 . A C 80 Pass N=2 F=5;U=4Output:

sc2/60 55 . G T 76 Pass N=2 F=5;U=4 sc2/60 55 . G C 72 Pass N=2 F=5;U=4

sc2/80         20      .        A       T        86      PASS     N=2      F=5;U=4
sc2/80         20      .        A       C        80      PASS     N=2      F=5;U=4

sc2/60         55      .        G       T        76      PASS     N=2      F=5;U=4 
sc2/60         55      .        G       C        72      PASS     N=2      F=5;U=4

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2). Logic: If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1:

sc2/80 20 . A T 86 Pass N=2 F=5;U=4

sc2/60 55 . G T 76 Pass N=2 F=5;U=4

sc2/68 20 . T C 71 Pass N=2 F=5;U=4

sc2/24 24 . T G 31 Pass N=2 F=5;U=4

File2:

sc2/80 20 . A C 80 Pass N=2 F=5;U=4

sc2/60 55 . G C 72 Pass N=2 F=5;U=4

sc2/68 20 . T C 71 Pass N=2 F=5;U=4

sc2/10 24 . T G 31 Pass N=2 F=5;U=4

sc2/40 59 . T G 31 Pass N=2 F=5;U=4

sc2/24 24 . A G 38 Pass N=2 F=5;U=4

OUTPUT:

sc2/80 20 . A T 86 Pass N=2 F=5;U=4 sc2/80 20 . A C 80 Pass N=2 F=5;U=4

sc2/60 55 . G T 76 Pass N=2 F=5;U=4 sc2/60 55 . G C 72 Pass N=2 F=5;U=4

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2).

Logic:
If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1:

sc2/80         20      .        A       T         86       PASS     N=2     F=5;U=4
sc2/60         55      .        G       T         76       PASS     N=2     F=5;U=4 
sc2/68         20      .        T       C         71       PASS     N=2     F=5;U=4
sc2/24         24      .        T       G         31       PASS     N=2     F=5;U=4

File2:

sc2/80         20      .        A        C        80      PASS    N=2       F=5;U=4
sc2/60         55      .        G        C        72      PASS    N=2       F=5;U=4 
sc2/68         20      .        T        C        71      PASS    N=2       F=5;U=4 
sc2/10         24      .        T        G        31      PASS    N=2       F=5;U=4
sc2/40         59      .        T        G        31      PASS    N=2       F=5;U=4
sc2/24         24      .        A        G        38      PASS    N=2       F=5;U=4

Output:

sc2/80         20      .        A       T        86      PASS     N=2      F=5;U=4
sc2/80         20      .        A       C        80      PASS     N=2      F=5;U=4

sc2/60         55      .        G       T        76      PASS     N=2      F=5;U=4 
sc2/60         55      .        G       C        72      PASS     N=2      F=5;U=4
deleted 26 characters in body
Source Link
Namrata
  • 519
  • 1
  • 7
  • 15

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2).

Logic:
Logic: If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1: File1:

sc2/80         20      .        A       T         86       PASS     N=2     F=5;U=4
sc2/60         55      .        G       T         76       PASS     N=2     F=5;U=4 
sc2/68         20      .        T       C         71       PASS     N=2     F=5;U=4
sc2/24         24      .        T       G         31       PASS     N=2     F=5;U=4

sc2/80 20 . A T 86 Pass N=2 F=5;U=4

File2: sc2/60 55 . G T 76 Pass N=2 F=5;U=4

sc2/80         20      .        A        C        80      PASS    N=2       F=5;U=4
sc2/60         55      .        G        C        72      PASS    N=2       F=5;U=4 
sc2/68         20      .        T        C        71      PASS    N=2       F=5;U=4 
sc2/10         24      .        T        G        31      PASS    N=2       F=5;U=4
sc2/40         59      .        T        G        31      PASS    N=2       F=5;U=4
sc2/24         24      .        A        G        38      PASS    N=2       F=5;U=4

sc2/68 20 . T C 71 Pass N=2 F=5;U=4

Output: sc2/24 24 . T G 31 Pass N=2 F=5;U=4

sc2/80         20      .        A       T        86      PASS     N=2      F=5;U=4
sc2/80         20      .        A       C        80      PASS     N=2      F=5;U=4

sc2/60         55      .        G       T        76      PASS     N=2      F=5;U=4 
sc2/60         55      .        G       C        72      PASS     N=2      F=5;U=4

File2:

sc2/80 20 . A C 80 Pass N=2 F=5;U=4

sc2/60 55 . G C 72 Pass N=2 F=5;U=4

sc2/68 20 . T C 71 Pass N=2 F=5;U=4

sc2/10 24 . T G 31 Pass N=2 F=5;U=4

sc2/40 59 . T G 31 Pass N=2 F=5;U=4

sc2/24 24 . A G 38 Pass N=2 F=5;U=4

OUTPUT:

sc2/80 20 . A T 86 Pass N=2 F=5;U=4 sc2/80 20 . A C 80 Pass N=2 F=5;U=4

sc2/60 55 . G T 76 Pass N=2 F=5;U=4 sc2/60 55 . G C 72 Pass N=2 F=5;U=4

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2).

Logic:
If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1:

sc2/80         20      .        A       T         86       PASS     N=2     F=5;U=4
sc2/60         55      .        G       T         76       PASS     N=2     F=5;U=4 
sc2/68         20      .        T       C         71       PASS     N=2     F=5;U=4
sc2/24         24      .        T       G         31       PASS     N=2     F=5;U=4

File2:

sc2/80         20      .        A        C        80      PASS    N=2       F=5;U=4
sc2/60         55      .        G        C        72      PASS    N=2       F=5;U=4 
sc2/68         20      .        T        C        71      PASS    N=2       F=5;U=4 
sc2/10         24      .        T        G        31      PASS    N=2       F=5;U=4
sc2/40         59      .        T        G        31      PASS    N=2       F=5;U=4
sc2/24         24      .        A        G        38      PASS    N=2       F=5;U=4

Output:

sc2/80         20      .        A       T        86      PASS     N=2      F=5;U=4
sc2/80         20      .        A       C        80      PASS     N=2      F=5;U=4

sc2/60         55      .        G       T        76      PASS     N=2      F=5;U=4 
sc2/60         55      .        G       C        72      PASS     N=2      F=5;U=4

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2). Logic: If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1:

sc2/80 20 . A T 86 Pass N=2 F=5;U=4

sc2/60 55 . G T 76 Pass N=2 F=5;U=4

sc2/68 20 . T C 71 Pass N=2 F=5;U=4

sc2/24 24 . T G 31 Pass N=2 F=5;U=4

File2:

sc2/80 20 . A C 80 Pass N=2 F=5;U=4

sc2/60 55 . G C 72 Pass N=2 F=5;U=4

sc2/68 20 . T C 71 Pass N=2 F=5;U=4

sc2/10 24 . T G 31 Pass N=2 F=5;U=4

sc2/40 59 . T G 31 Pass N=2 F=5;U=4

sc2/24 24 . A G 38 Pass N=2 F=5;U=4

OUTPUT:

sc2/80 20 . A T 86 Pass N=2 F=5;U=4 sc2/80 20 . A C 80 Pass N=2 F=5;U=4

sc2/60 55 . G T 76 Pass N=2 F=5;U=4 sc2/60 55 . G C 72 Pass N=2 F=5;U=4

Fix formatting.
Source Link
user26112
user26112

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2). Logic:

Logic:
If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1:File1:

File2:File2:

OUTPUT:Output:

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2). Logic: If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1:

File2:

OUTPUT:

I need to compare two files, File1 and File2 (Separated by space) using 4 fields (Field 1, 2, 4 and 5 of File 1 with field1, 2, 4 and 5 of File2).

Logic:
If column 1, 2 and 4 of File 1 matches with column 1, 2 and 4 of File 2 and there is a mismatch at column 5 then both the lines from File 1 and File 2 are concatenated redirected as output. Therefore, the output file only contains those lines where Column 1, 2 and 4 of File1 and File2 matches and Column 5 does not match.

File1:

File2:

Output:

added 60 characters in body
Source Link
jordanm
  • 43.6k
  • 10
  • 121
  • 115
Loading
Source Link
Namrata
  • 519
  • 1
  • 7
  • 15
Loading