Sample Header Ad - 728x90

Help with creating a bash code to compare two different files

0 votes
0 answers
62 views
I'm currently encountering some challenges while working on a bash script in the Linux terminal to perform the following tasks: 1. Compare the values in the third column of two different files line by line. 2. If the values are different, save in a third output file the identifier from the second column of the input files, along with the corresponding values from both File 1 and File 2, similar to the "desired first output" example provided. 3. Additionally, create a fourth output file to tally the occurrences of each unique qualitative difference, taking into account the order (for example: 9690 0 ≠ 0 9690) while disregarding the identifier. This is illustrated in the "desired last output" example. Any assistance or guidance in achieving this is greatly appreciated! FILE 1
U	E100033877L1C016R01601996031		0	140	0:106
U	E100033877L1C023R03303214633		0	140	0:106
C	E100033877L1C022R01901579971		27996	140	27996:1 0:7 27996:23 0:75
C	E100033877L1C023R02603225407		27996	140	0:32 27996:23 0:7 27996:1 0:3 27996:4 0:36
C	E100033877L1C020R02602000209		0	140	0:106
C	E100033877L1C023R03303214633		27996	140	27996:3 0:4 27996:5 0:94
C	E100033877L1C023R03101740491		9690	140	9690:13 0:8 9690:7 0:13 9690:9 0:56
C	E100033877L1C006R00200498634		9690	140	9690:71 0:35
C	E100033877L1C009R03603066069		27996	140	0:50 27996:2 0:1 27996:10 0:6 27996:11 0:26
C	E100033877L1C005R03300436825		27996	140	27996:3 0:6 27996:3 0:3 27996:5 0:86
FILE2
U	E100033877L1C016R01601996031		0	140	0:106
U	E100033877L1C023R03303214633		0	140	0:106
C	E100033877L1C022R01901579971		27996	140	27996:1 0:7 27996:23 0:75
C	E100033877L1C023R02603225407		27996	140	0:32 27996:23 0:7 27996:1 0:3 27996:4 0:36
C	E100033877L1C020R02602000209		27996	140	0:19 27996:4 0:3 27996:1 0:7 27996:23 0:49
C	E100033877L1C023R03303214633		27996	140	27996:3 0:4 27996:5 0:94
U	E100033877L1C023R03101740491		0	140	0:106
U	E100033877L1C006R00200498634		0	140	4840:106
C	E100033877L1C009R03603066069		4840	140	0:50 27996:2 0:1 27996:10 0:6 27996:11 0:26
C	E100033877L1C005R03300436825		27996	140	27996:3 0:6 27996:3 0:3 27996:5 0:86
DESIRED FIRST OUTPUT
E100033877L1C020R02602000209		0	27996
E100033877L1C023R03101740491		9690	0	
E100033877L1C006R00200498634		9690	0	
E100033877L1C009R03603066069		27996	4840
DISIRED LAST OUTPUT
2	9690	0	
1	0	27996
1	27996	4840
Asked by duduzba (1 rep)
Oct 13, 2023, 02:50 AM
Last activity: Oct 13, 2023, 02:51 AM