Compare 2 text files and display the difference between them (PowerShell or CMD)

152 views Asked by At

I have 2 text files text1.txt contains:

fc1/1 storage
fc1/5 switch
fc1/7 replication

text2.txt contains:

fc1/1 storage
fc1/5 nas
fc1/7 replication

I want a script that compares the 2 text files and generate text found on text2.txt but not on text1.txt in a text file named difference.txt

difference.txt contains

fc1/5 nas

any ideas?

1

There are 1 answers

0
MC ND On

Maybe ...

findstr /v /g:text1.txt text2.txt  > difference.txt

Search text2.txt for lines not matching (/v) lines in text1.txt