MS-DOS 6.22 COMP vs FC Command: Key Differences
In MS-DOS 6.22, both COMP and FC are
utilities used to compare files, but they differ significantly in their
operation, flexibility, and output. While COMP performs a
strict, byte-by-byte comparison primarily intended for identically sized
files, FC (File Compare) provides advanced comparison
modes, including line-by-line text analysis with automatic
resynchronization and detailed binary comparison that can handle files
of differing lengths.
The COMP Command
The COMP utility is an older, simpler tool designed to
compare the contents of two files or sets of files byte by byte.
- File Size Restriction:
COMPchecks the file sizes before beginning the comparison. If the files are different sizes,COMPdisplays the message "Files are different sizes" and immediately terminates the comparison without analyzing the contents. - Mismatch Handling: If the file sizes match,
COMPcompares the bytes sequentially. When it encounters differences, it reports the byte offset (location) and the mismatching values, typically in hexadecimal format. - Error Limit: To prevent flooding the screen when
comparing drastically different files,
COMPautomatically aborts the operation after encountering 10 mismatches.
The FC Command
The FC utility is a more powerful and versatile
replacement for COMP. It features two distinct operational
modes: ASCII mode (default for text files) and Binary mode
(/B).
- ASCII / Text Comparison: In text mode,
FCcompares two files line by line rather than byte by byte. When it detects a discrepancy, it prints the differing lines and then searches down the files to find where the text resynchronizes. This makes it ideal for comparing source code, configuration files, and documents, as it can account for inserted or deleted lines without failing. - Binary Comparison (
/B): When executed with the/Bswitch,FCperforms a byte-by-byte comparison similar toCOMP, but it does not terminate if the files are different sizes. It continues comparing until the end of the shorter file is reached, then reports that the longer file contains extra data. - Customization Options:
FCincludes various switches, such as/Nto display line numbers during an ASCII comparison,/Cto ignore case sensitivity, and/Wto compress consecutive tabs and spaces.
Summary of Differences
- Resynchronization:
FCcan resynchronize lines in text files after finding a difference;COMPcannot resynchronize. - Different File Sizes:
COMPrefuses to compare files of unequal size, whereasFCcan compare them in both text and binary modes. - Output Format:
COMPoutputs differences primarily as hexadecimal byte offsets, whileFCoutputs human-readable text lines in ASCII mode or hexadecimal offsets in binary mode. - Mismatch Threshold:
COMPstops after 10 errors, whileFCcontinues through the entire file (unless limited by the text buffer during resynchronization).