Comp Command


Comp Command is a Microsoft Windows command for performing a bytewise comparison of the contents of different files. The comp command is typically used for byte-by-byte comparison of text files, or for a comparison of the contents of two directories.

Comp Command examples

To compare C:\file1.txt and C:\file2.txt and show the differences between them as characters, type the following:

comp C:\file1.txt C:\file2.txt /a

You can also use wildcards to specify multiple files. For the full syntax of this command, type comp/? at the command prompt.

Comp Command



Remarks

  • During the comparison, comp displays messages that identify the locations of unequal information between the files. Each message indicates the offset memory address of the unequal bytes and the contents of the bytes (in hexadecimal notation unless the /a or /d command-line parameter is specified). Messages appear in the following format:
Compare error at OFFSET xxxxxxxx 
file1 = xx 
file2 = xx

After ten unequal comparisons, comp stops comparing the files and displays the following message:

10 Mismatches - ending compare
  • If you omit necessary components of either data1 or data2, or if you omit data2 entirely, this command prompts you for the missing information.
  • If data1 contains only a drive letter or a directory name with no file name, this command compares all of the files in the specified directory to the file specified in data1.
  • If data2 contains only a drive letter or a directory name, the default file name for data2 becomes the same name as for data1.
  • If the comp command can’t find the specified files, it will prompt you with a message about whether you want to compare additional files.
  • The files that you compare can have the same file name, provided they’re in different directories or on different drives. You can use wildcard characters (* and ?) to specify file names.
  • You must specify /n to compare files of different sizes. If the file sizes are different and /n isn’t specified, the following message is displayed:
Files are different sizes Compare more files (Y/N)?

To compare these files anyway, press N to stop the command. Then, run the comp command again, using the /n option to compare only the first portion of each file.



See also

Editor

Articles posted after being checked by editors.

Recent Content