This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Compares the contents of two files or sets of files byte-by-byte. These files can be stored on the same drive or on different drives, and in the same directory or in different directories. When this command compares files, it displays their location and file names. If used without parameters,comp prompts you to enter the files to compare.
comp [<data1>] [<data2>] [/d] [/a] [/l] [/n=<number>] [/c]| Parameter | Description |
|---|---|
<data1> | Specifies the location and name of the first file or set of files that you want to compare. You can use wildcard characters (* and?) to specify multiple files. |
<data2> | Specifies the location and name of the second file or set of files that you want to compare. You can use wildcard characters (* and?) to specify multiple files. |
| /d | Displays differences in decimal format. (The default format is hexadecimal.) |
| /a | Displays differences as characters. |
| /l | Displays the number of the line where a difference occurs, instead of displaying the byte offset. |
/n=<number> | Compares only the number of lines that are specified for each file, even if the files are different sizes. |
| /c | Performs a comparison that is not case-sensitive. |
| /off[line] | Processes files with the offline attribute set. |
| /? | Displays Help at the command prompt. |
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 xxxxxxxxfile1 = xxfile2 = xxAfter ten unequal comparisons,comp stops comparing the files and displays the following message:
10 Mismatches - ending compare
If you omit necessary components of eitherdata1 ordata2, or if you omitdata2 entirely, this command prompts you for the missing information.
Ifdata1 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 indata1.
Ifdata2 contains only a drive letter or a directory name, the default file name fordata2 becomes the same name as fordata1.
If thecomp 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 sizesCompare more files (Y/N)?To compare these files anyway, pressN to stop the command. Then, run thecomp command again, using the/n option to compare only the first portion of each file.
If you use wildcard characters (* and?) to specify multiple files,comp finds the first file that matchesdata1 and compares it with the corresponding file indata2, if it exists. Thecomp command reports the results of the comparison for each file matchingdata1. When finished,comp displays the following message:
Compare more files (Y/N)?
To compare more files, pressY. Thecomp command prompts you for the locations and names of the new files. To stop the comparisons, pressN. When you pressY, you're prompted for which command-line options to use. If you don't specify any command-line options,comp uses the ones you specified before.
To compare the contents of the directoryc:\reports with the backup directory\\sales\backup\april, type:
comp c:\reports \\sales\backup\aprilTo compare the first ten lines of the text files in the\invoice directory and display the result in decimal format, type:
comp \invoice\*.txt \invoice\backup\*.txt /n=10 /dWas this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?