Compares two files and displays the differences between them.
To make an text comparison:
FC [/A | [/U] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/W] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2
To make a binary comparison:
FC /B [drive1:][path1]filename1 [drive2:][path2]filename2
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.
Equivalent Linux BASH commands:
comm - Compare two sorted files line by line.
cmp - Compare two files.
diff - Display the differences between two files.
diff3 - Show differences among three files.
sdiff - merge two files interactively.
When you use FC for an ASCII comparison, the operating system reports differences between two files by displaying the name of the first file, followed by the last line to match in both files, followed by the lines from filename1 that differ between the files, followed by the first line to match in both files. The operating system then displays the name of the second file, followed by the last line to match, followed by the lines from filename 2 that differ, followed by the next line to match.
The operating system uses this format to report mismatches found during a binary comparison:
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.
You can use wildcards (* and ?) in either of the filenames you specify with the FC command. If you use a wildcard in filename1, FC compares all the specified files to the file specified by filename2. If you use a wildcard in filename2, FC uses the corresponding value from filename1.
When comparing ASCII files, FC uses an internal buffer (large enough to hold 100 lines) as storage. If the files are larger than the buffer, FC compares what it can load into the buffer. If FC does not find a match in the loaded portions of the files, it stops and displays the message:
Resynch failed. Files are too different.
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. The output is the same as that for files that fit completely in memory.
Suppose you want to make an ASCII comparison of two text files that are named MONTHLY.RPT and SALES.RPT, and you want to display the results in abbreviated format. To make this comparison, type:
FC /A MONTHLY.RPT SALES.RPT
To make a binary comparison of two batch files named PROFITS.BAT and EARNINGS.BAT, type:
FC /B PROFITS.BAT EARNINGS.BAT
The results of this command will be similar to:
00000002: 72 43 00000004: 65 3A 0000000E: 56 92 00000012: 6D 5C 00000013: 0D 7C 00000014: 0D 0A 00000015: 0A 0D 0000001E: 43 7A 0000001F: 09 0A 00000022: 72 44 ... ... ... 000005E0: 00 61 000005E1: 00 73 000005E2: 00 73 000005E3: 00 69 000005E4: 00 67 000005E5: 00 6E 000005E6: 00 6D 000005E7: 00 65 000005E8: 00 6E FC: EARNINGS.BAT longer than PROFITS.BAT
If the PROFITS.BAT and EARNINGS.BAT files were identical, FC would display the message:
FC: no differences encountered
To compare every .BAT file in the current directory with the file NEW.BAT, type:
FC *.BAT NEW.BAT
To compare the file NEW.BAT on drive C with the file NEW.BAT on drive D, type:
FC C:NEW.BAT D:*.BAT
To compare each batch file in the root directory on drive C to the file with the same name in the root directory on drive D, type:
FC C:\*.BAT D:\*.BAT