本文介绍了Powershell 比较文本文件并显示差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要进行文件比较并想使用 Powershell.我需要一个列出所有差异的输出文件.下面是一个好的开始,但我需要文件包含行号,并且生成的输入对象目前在 89 个字符后也被截断 - 我需要显示整行:
I need to do a file comparison and want to use Powershell. I need an output file listing all of the differences. The below is a good start, but I need the file to inlcude line numbers, and the resulting Input Object currently also gets cut off after 89 characters - I need the full line to display:
compare-object (get-content $File1) (get-content $File2) | Out-File $Location
推荐答案
输入对象被默认显示截断.要将整行保存到文件:
The Input Object is being truncated by the default display. To save the entire line to a file:
compare-object (get-content $File1) (get-content $File2) | format-list | Out-File $Location
这篇关于Powershell 比较文本文件并显示差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!