I want to compare two pipe delimited text files and find out the difference between two files using Linux script and write/copy the difference to output file.
scenario 1
File 1
5756366|99|HOLDER, CTLY 6X12X15.5 PLST|HOLDER, CUTLERY 6X12X15.5 PLASTIC COPPER FINISH W/|INSERT|A
1516020|99|CHEESE, CRM GRDN VEG SPRED|CHEESE, CREAM GARDEN VEGETABLE SPREAD PLASTIC TUB|REF|A
5086368|99|MAT, CRPT 4'X6' OLEFN CHRCL|MAT, CARPET 4'X6' OLEFIN CHARCOAL CATALINA||A
File 2
5756366|99|HOLDER, CTLY 6X12X15.5 PLST|HOLDER, CUTLERY 6X12X15.5 PLASTIC COPPER FINISH W/|INSERT|A
1516020|99|CHEESE, CRM GRDN VEG SPRED|CHEESE, CREAM GARDEN VEGETABLE SPREAD PLASTIC TUB|REF|A
5086368|99|MAT, CRPT 4'X6' OLEFN CHRCL|MAT, CARPET 4'X6' OLEFIN CHARCOAL CATALINA||A
5639166|99|COVER, DOME TRAY 12X20 PCRBN|COVER, CLEAR SIDE CU|T OUT W/ HINGED DOOR LID|A
Here, I want to get the difference between two files. In this case, the file 2 is having extra record 5639166|99|COVER, DOME TRAY 12X20 PCRBN|COVER, CLEAR SIDE CU|T OUT W/ HINGED DOOR LID|A and this should be saved to a Diff File as shown below
Diff File
5639166|99|COVER, DOME TRAY 12X20 PCRBN|COVER, CLEAR SIDE CU|T OUT W/ HINGED DOOR LID|A
Scenario 2
File 1
5756366|99|HOLDER, CTLY 6X12X15.5 PLST|HOLDER, CUTLERY 6X12X15.5 PLASTIC COPPER FINISH W/|INSERT|A 1516020|99|CHEESE, CRM GRDN VEG SPRED|CHEESE, CREAM GARDEN VEGETABLE SPREAD PLASTIC TUB|REF|A
File 2
5756366|99|HOLDER, CTLY 6X12X15.5 PLST|HOLDER, CUTLERY 6X12X15.5 PLASTIC COPPER FINISH W/|INSERT|A 1516020|99|CHEESE, CRM GRDN VEG SPRED TEST|CHEESE, CREAM GARDEN VEGETABLE SPREAD PLASTIC TUB|REF|I
Here in this scenario, there is a change in the data for 1516020 record,So in the diff File i should have only 1516020 record as below
Diff File
1516020|99|CHEESE, CRM GRDN VEG SPRED TEST|CHEESE, CREAM GARDEN VEGETABLE SPREAD PLASTIC TUB|REF|I
Would any one please help me out with Linux script for the above scenarios.
diff
again?17 cheese
and42 mouse
, would you be able to do this yourself? If yes, tell us how you would do it. If not, why are you asking a question with an arbitrary extra complication? Ask one question at a time, and do research first. (2) If you were dealing with files that consisted of lines with under 200 characters, would that make the problem easier? If not, use example data that people can look at and read, like17|cheese
and42|mouse
, rather than 200-character long lines full of capital letters.diff
command.man diff
andman comm
on your computer, try something and then come back with a question if you need help with whatever it is you tried.