Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers

How do I diff two text files in Windows Powershell?

submited by
Style Pass
2024-06-09 07:00:03

Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

I have two text files and want to find the differences between them using Windows Powershell. Is there something similar to the Unix diff tool available? Or is there another other way I haven't considered?

Figured it out myself. Because Powershell works with .net objects rather than text, you need to use get-content to expose the contents of the text files. So to perform what I was trying to do in the question, use:

Or you could use the DOS fc command like so (This shows the output of both files so you will have to scan for the differences):

Leave a Comment