Fc

From aldeid
Jump to navigation Jump to search

Description

Compares two files and displays the differences between them. This command is convenient to check whether modifications have been successfully applied on a patched file.

Usage

Syntax

fc [/a] [/b] [/c] [/l] [/lbn] [/n] [/t] [/u] [/w] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2

Parameters

/a
Abbreviates the output of an ASCII comparison. Instead of displaying all of the lines that are different, fc displays only the first and last line for each set of differences.
/b
Compares the files in binary mode. 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
Ignores the case of letters.
/l
Compares 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 files, except files with the following file extensions: .exe, .com, .sys, .obj, .lib, or .bin.
/lbn
Sets the n number of lines for the internal line buffer. The default length of the line buffer is 100 lines. If the files that you are comparing have more than this number of consecutive differing lines, fc cancels the comparison.
/n
Displays the line numbers during an ASCII comparison.
/t
Prevents 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
Compresses 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
Specifies the 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
Specifies the location and name of the first file you want to compare. Filename1 is required.
[drive2:][path2]filename2
Specifies the location and name of the second file you want to compare. Filename2 is required.
/?
Displays help at the command prompt.

Example

On Windows, simply issue following command to visualize differences between 2 files:

C:\>fc getdown.exe getdown-patched.exe
Comparaison des fichiers getdown.exe et GETDOWN-PATCHED.EXE
00000698: 0F 90
00000699: 85 90
0000069A: CF 90
0000069B: 01 90
0000069C: 00 90
0000069D: 00 90

The same thing could be done on *nix with following command:

$ cmp -l getdown.exe getdown-patched.exe | gawk '{printf "%08X %02X %02X\n", $1, strtonum(0$2), strtonum(0$3)}' 
00000699 0F 90
0000069A 85 90
0000069B CF 90
0000069C 01 90
0000069D 00 90
0000069E 00 90

Comments