使用Powershell或其他方式比较2个大文件?

时间:2018-10-30 09:29:59

标签: powershell

我正在尝试比较2个非常大的文件,两个文件中的单词均超过900万个,每个文件的大小约为340mb。

我还尝试了Beyond compare之类的程序,以及其他一些程序。程序将比较这两个文件,但是当我尝试保存文件时会崩溃。

当我尝试使用Powershell时,似乎无法正常工作:

$folder1 = Get-Content C:\Newfolder\ParentGUID.txt
$folder2 = Get-Content C:\Newfolder\GUID.txt

Compare-Object $folder1 $folder2 -IncludeEqual -ExcludeDifferent 

$folder1 = Get-Content C:\Newfolder\ParentGUID.txt | ForEach-Object { $_.Trim() }
$folder2 = Get-Content C:\Newfolder\GUID.txt | ForEach-Object { $_.Trim() }

Compare-Object $folder1 $folder2 -IncludeEqual -ExcludeDifferent

out-file c:\Newfolder\myfolder.txt

还有

$Acer   = Import-Csv -Path C:\Newfolder\GUID.txt
$SAS    = Import-Csv -Path C:\Newfolder\ParentGUID.txt
$Header = $Acer | Get-Member | Where-Object -FilterScript {$_.MemberType -eq 'NoteProperty'} | Select-Object -ExpandProperty Name
Compare-Object -ReferenceObject $Acer -DifferenceObject $SAS -Property 'Unique ID' -PassThru | Select-Object -Property $Header |
Export-Csv -Path C:\Newfolder\NewStudents.txt -NoTypeInformation

0 个答案:

没有答案