FC.exe – Windows CMD Command
Compare the contents of two files or sets of files. Display any lines which do NOT match.
Syntax
FC [options] [drive1:][path1] filename1 [drive2:][path2] filename2
Options
/A Abbreviate the output of an ASCII comparison, display only first and last lines
for each set of differences.
/B Perform a binary comparison. FC compares the two files byte by byte and does not attempt
to resynchronize the files after finding a mismatch.
This is the default mode for comparing files that have the following file extensions:
.exe, .com, .sys, .obj, .lib, or .bin.
/C Do a case insensitive string comparison
/L Compare the files in ASCII mode. Fc compares the two files line by line and attempts to resynchronize
the files after finding a mismatch.
This is the default mode for comparing non binary files, see /B.
/LBn Set the n number of lines for the internal line buffer. The default length of the line buffer is 100 lines.
If the files being compared have more than this number of consecutive differing lines, FC cancels the comparison.
/N Display line numbers during an ASCII comparison.
/T Prevent FC from converting tabs to spaces.
The default behavior is to treat tabs as spaces, with stops at each eighth character position.
/U Compares files as Unicode text files.
/W Compress white space (that is, tabs and spaces) during the comparison.
If a line contains many consecutive spaces or tabs, /w treats these characters as a single space.
When used with the /W command-line option, FC ignores (and does not compare) white space at the beginning and end of a line.
/nnnn The a number of consecutive lines that must match before FC considers the files to be resynchronized.
If the number of matching lines in the files is less than nnnn, FC displays the matching lines as differences.
The default value is 2.
[ drive1 : ][ path1 ] filename1 The location and name of the first file you want to compare.
Filename1 is required.
[ drive2 : ][ path2 ] filename2 The location and name of the second file you want to compare.
Filename2 is required.
Wildcards ( * and ? ) may be used with filename1 or filename2, FC will then compare all the matching files.
Powershell also has an Alias FC for the Format-Custom cmdlet, therefore to run the ‘old’ FC under PowerShell you can explicitly run C:\windows\system32\fc.exe
Errorlevels
FC will set an ErrorLevel as follows:
-1 Invalid syntax (e.g. only one file passed)
0 The files are identical.
1 The files are different.
2 Cannot find at least one of the files.
For an invalid switch (with two passed files) an error message is printed but the errorlevel is not changed.
The messages returned by FC are language/locale dependent, so to reliably identify 2 identical files use redirection syntax:
FC File1.txt File2.txt >NUL && Echo Same || Echo Different or error
Comparison order
When FC is used for an ASCII comparison, it will display differences between two files in the following order:
- Name of the first file
- Lines from filename1 that differ between the files
- First-line to match in both files
- Name of the second file
- Lines from filename2 that differ
- First-line to match
Binary Comparisons
/B displays mismatches found during a binary comparison as follows: xxxxxxxx: yy zz
The value of xxxxxxxx specifies the relative hexadecimal address for the pair of bytes, measured from the beginning of the file. Addresses start at 00000000.
The hexadecimal values for yy and zz represent the mismatched bytes from filename1 and filename2, respectively.
When comparing binary files that are larger than available memory, FC compares both files completely, overlaying the portions in memory with the next portions from the disk.
PowerShell
Like every other external command, FC can be run under PowerShell instead of CMD, however, there is one extra complication for FC and that is the standard PowerShell alias FC which redirects to the Format-Custom cmdlet.
To avoid that, use the call operator to run FC.exe:
& fc.exe
Example:
Make a binary comparison of two DLL files:
C:\> FC /b new.dll old.dll
Make an ASCII comparison of two text files and display the result in abbreviated format:
C:\> FC /a C:\demo\input.txt H:\work\output.txt
As I website possessor I believe the content material here is rattling great , appreciate it for your hard work. You should keep it up forever! Good Luck.
Your house is valueble for me. Thanks!…
I¦ve been exploring for a bit for any high-quality articles or weblog posts on this kind of house . Exploring in Yahoo I eventually stumbled upon this website. Studying this info So i am satisfied to show that I’ve an incredibly good uncanny feeling I found out exactly what I needed. I such a lot no doubt will make sure to do not put out of your mind this site and provides it a look on a continuing basis.
Hello.This post was extremely remarkable, especially because I was browsing for thoughts on this topic last week.