How to remove a line from txt file A if that line is present in the txt file B?

allaripostkast

Prominent
Sep 19, 2017
3
0
520
1
I have 2 txt files, file A and file B. Some lines in file A are the same as in file B. I need to run file A "against" file B and delete all lines from file A that are already present in file B.

How can I achieve this?
 

allaripostkast

Prominent
Sep 19, 2017
3
0
520
1
I found a stupid easy solution. Get TEDNotepad, paste in file B content, wite a line of === or whatever symbol then paste in the content of file A below it. Select all and press Ctrl + Shift + X. The content after the === line is the end result that was needed - unique lines compared to file B.
 

raisonjohn

Estimable
Herald
Feb 22, 2015
57
0
4,660
25
You can use a workaround by copy-pasting FileA.txt to MS Word FileA.doc and FileB.txt to MS Word FileB.doc.

Then, go to Review Menu and Click Compare. In the Compare Window, just select FileA.doc as original document and select FileB.doc as revised document. Click OK.

MS Word will highlight the differerences/changes/inserted words in both documents.

Delete all lines from FileA.doc that are already present in FileB.doc.

Copy all text in FileA.doc. Paste back/replace/update to Notepad in FileA.txt.

You can also eliminate the copy-pasting from txt to doc, as you can also proceed directly to MS Word and Compare txt files (in the Compare window, just click the folder open icon and change file type from doc to txt). But save as first so that the original txt files will serve as backup in case you accidentally delete wrong lines/infos.
 
If you are going to do that by hand - there're many file-compare applications which will compare text files line-by-line (eg under Windows, WinMerge is pretty good one). Depending on the OS you're using, you can create a script file reading source file line by line, checking for this line in the second file using grep-like utility, and creating a resulting file only if match is not found.
 

allaripostkast

Prominent
Sep 19, 2017
3
0
520
1
I found a stupid easy solution. Get TEDNotepad, paste in file B content, wite a line of === or whatever symbol then paste in the content of file A below it. Select all and press Ctrl + Shift + X. The content after the === line is the end result that was needed - unique lines compared to file B.
 
Thread starter Similar threads Forum Replies Date
omar muzzammil Apps General Discussion 1
B Apps General Discussion 1
T Apps General Discussion 1
A Apps General Discussion 3
M Apps General Discussion 1
A Apps General Discussion 7
B Apps General Discussion 2
B Apps General Discussion 1
H Apps General Discussion 1
C Apps General Discussion 2
P Apps General Discussion 5
B Apps General Discussion 2
P Apps General Discussion 1
P Apps General Discussion 3
I Apps General Discussion 3
W Apps General Discussion 3
T Apps General Discussion 3
A Apps General Discussion 1
EricLane Apps General Discussion 2
L Apps General Discussion 8

ASK THE COMMUNITY