Quantcast
Channel: MSDN Blogs
Viewing all articles
Browse latest Browse all 5308

Compare two text files with PowerShell

$
0
0

Many of the times, we have need to compare 2 code files which are identical but some minor differences, mainly due to spelling/typing mistakes.

This script tries to attend this issue by comparing 2 files line by line ignoring white space, tabs, line breaks.

Here is sample output:

.compareTextFiles.ps1 -inputFilePath $leftFilePath -compareFilePath $rightFilePath
********************************************
Line number 17
table is for CRUD methods
table is for CRUD methods
********************************************

********************************************
Line number 117
', '.join('?', * len(values))
', '.join('?' * len(values))
********************************************

********************************************
Line number 135
values = [rec[v] for v in klist] # a list of values ordered by key
values = [rec[v] for v in klist] # a list of values ordered by key
********************************************

As we can see from about output, on line no 117, the input file has extra ","

 

Download Link:

compareTextFiles


Viewing all articles
Browse latest Browse all 5308

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>