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

      FC /B pathname1 pathname2

      FC [options] pathname1 pathname2

   /B  : Perform a binary comparison.

   /C  : Do a case insensitive string comparison

   /A  : Displays only first and last lines for each set of differences.

   /U  : Compare files as UNICODE text files.
   /L  : Compares files as ASCII text. (default)

   /N  : Display line numbers (ASCII only)

   /LBn: Limit the number of lines that will be read, "n" sets a maximum number
         of consecutive differing lines after which the File Comparison will abort (resync failed)
         When FC aborts then "n" number of mismatches will be shown.
         default=100 lines.

  /nnnn  : Specify a number of consecutive lines that must match after a mismatch.
           This can be used to prevent the display of the two files from getting 
           too out of sync

  /T     : Do not expand tabs to spaces.
  /W     : Compress white space (tabs and spaces) for comparison.

To compare sets of files, use wildcards in pathname1 and pathname2 parameters.

Powershell also has an Alias FC for the Format-Custom cmdlet, therefore to run the 'old' FC under powershell you need to explicitly run C:\windows\system32\fc.exe

The messages returned by FC are language/locale dependent, so to identify 2 identical files use redirection syntax:

   FC File1.txt File2.txt >NUL && Echo Same || Echo Different or error 


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.


If two files are compared and the four lines of text match as follows

1: different
2: same
3: same
4: different

Specifying /nnnn =2 the file compare will display the 4th line and continue
Specifying /nnnn =3 the file compare will halt at the 4th line (files too different)
Specifying /LB1 the file compare will halt after the first line

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


Q953929 - FC.exe command does not work correctly in Windows XP when files differ on every 128th byte
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
Powershell: Compare-Object - Compare the properties of objects, e.g. compare content of files.
Equivalent bash command (Linux): cmp - Compare two files

© Copyright SS64.com 1999-2015
Some rights reserved