I have two 4GB temporary files.
I did a quick visual inspection using a hex editor and see they appear to be the same. Is there a command I can use in something like PowerShell to binary compare the two so I can be certain they are the same?
I have two 4GB temporary files.
I did a quick visual inspection using a hex editor and see they appear to be the same. Is there a command I can use in something like PowerShell to binary compare the two so I can be certain they are the same?
As @dhiwakar-ravikumar already answered, you can use the "file compare" (fc
) Windows command to compare 2 files (or sets of files), and use the /b
parameter to do a binary comparison.
However, it should be noted that contrary to the "cmd" command shell, in PowerShell, the command has to be spelled out as fc.exe
to avoid the "fc
" alias to Format-Custom
to take precedence.
Like so:
fc.exe /b [<Drive1:>][<Path1>]<FileName1> [<Drive2:>][<Path2>]<FileName2>
Also note that if the extension of the files to compare is one of .exe
, .com
, .sys
, .obj
, .lib
or .bin
, a binary comparison is performed by default and the /b
parameter can be omitted to the same result.
.exe
extension to the command for PowerShell (which OP specifically asked about) and update the documentation link, but it was rejected as deviating too much from the original answer intent, so I tried to post it as a new answer as I think it is relevant information (someone even asked in a comment). When downvoting, I'd sincerely appreciate info on why and / or advice on a better couse of action.
There is a command in Windows which can give you a binary comparision of two files
fc /b <filename1> <filename2>
For more information - https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/fc.mspx?mfr=true
This works equally well on Windows 7
If you're looking for tools , there is an answer already - https://stackoverflow.com/questions/8166697/tool-for-comparing-2-binary-files-in-windows
Internal compare tool of Total Commander 64bit works fine on files over 2GB. (File -> Compare by content)
fc.exe works great in PowerShell but just for completeness, I'm adding the PowerShell docs version of compare below:
Compare-Object -ReferenceObject $(Get-Content textout.txt) -DifferenceObject $(Get-Content textout1.txt)
AsByteStream
parameter mentioned in the documentation but it was very memory hungry and inefficient (I didn't get it to terminate comparing ~1MiB files on my setup, even after several minutes).