Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,123 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I need you to help me study to propose a script that compares 2 text files and creates one for me with the same strings. How would you do it? I just need advice.
file1.txt
C:\tmp\1\11111.mp3
C:\tmp\1\11112.mp3
C:\tmp\3\11113.mp3
file2.txt
C:\tmp\1\11111.mp3
C:\tmp\2\11112.mp3
C:\tmp\3\11113.mp3
result.txt
C:\tmp\1\11111.mp3
C:\tmp\3\11113.mp3
Use Compare-Object:
(Compare-Object -ReferenceObject (Get-Content c:\junk\file1.txt) -DifferenceObject (Get-Content c:\junk\file2.txt) -IncludeEqual -ExcludeDifferent).InputObject |
Out-File c:\junk\resultfile.txt