Compare the contents of two files or sets of files. Display any lines which do NOT match.

      FC [options] [drive1:][path1] filename1 [drive2:][path2] filename2

   /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


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:

  1. Name of the first file
  2. Lines from filename1 that differ between the files
  3. First line to match in both files
  4. Name of the second file
  5. Lines from filename2 that differ
  6. 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.


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


Make a binary comparison of two DLL files:

C:\> FC /b new.dll old.dll

Compare two files and report if they are identical:

C:\> (FC /B "new.dll" "old.dll" | Find "FC: no differences encountered") > nul && (Echo The Files match.)

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

# Oh lord won’t you buy me a Mercedes Benz, my friends all drive Porsches, I must make amends # ~ Janice Joplin

Related commands

COMP - Compare two files and display any characters which do NOT match.
FIND - Search for a text string in a file.
FINDSTR - Search for strings in files.
WinDiff - GUI to compare files.
Equivalent PowerShell: Compare-Object - Compare the properties of objects, e.g. compare content of files.
Equivalent bash command (Linux):cmp - Compare two files.

Copyright © 1999-2024 SS64.com
Some rights reserved