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: COMP checks the file sizes before beginning the comparison. If the files are different sizes, COMP displays the message "Files are different sizes" and immediately terminates the comparison without analyzing the contents.
  • Mismatch Handling: If the file sizes match, COMP compares 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, COMP automatically 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, FC compares 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 /B switch, FC performs a byte-by-byte comparison similar to COMP, 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: FC includes various switches, such as /N to display line numbers during an ASCII comparison, /C to ignore case sensitivity, and /W to compress consecutive tabs and spaces.

Summary of Differences

  • Resynchronization: FC can resynchronize lines in text files after finding a difference; COMP cannot resynchronize.
  • Different File Sizes: COMP refuses to compare files of unequal size, whereas FC can compare them in both text and binary modes.
  • Output Format: COMP outputs differences primarily as hexadecimal byte offsets, while FC outputs human-readable text lines in ASCII mode or hexadecimal offsets in binary mode.
  • Mismatch Threshold: COMP stops after 10 errors, while FC continues through the entire file (unless limited by the text buffer during resynchronization).