I have 2 text files and I need to export the “changes” to a new file. This means that the lines of the second file are compared with the first lines of the file, and if the line is not found there, then it will add it to the new (third) file.
The contents of the first file:
ABC 123 q1w2sd
DEF 321 sdajkn
Ghi 123 jsdnaj
JKL 456 jsd223
The second file contains:
ABC 123 XXXXXX
JKL 456 jsd223
DEF XXX sdajkn
Ghi 123 jsdnaj
Note that lines starting with ABC and DEF have changed. JKL just changed his place.
The output file should contain: ABC 123 XXXXXX DEF XXX sdajkn
How to do this using awk or sed?
Edit: also new lines in the second file should be considered as changes.
source share