Comp Command to compare the file contents byte by byte.
Comp command can compare two files resided on different drives or locations. When this command compares the files, it displays the locations and their file names. Without using parameters will prompts you to enter the files you want to compare.
Syntax
Comp Parameters
Parameters
File1 | Specifies location and name(s) of first file(s) to compare. |
File2 | Specifies location and name(s) of second files to compare. |
/D | Displays differences in decimal format. |
/A | Displays differences in ASCII characters. |
/L | Displays line numbers for differences. |
/N=number | Compares only the first specified number of lines in each file. |
/C | Disregards case of ASCII letters when comparing files. |
/OFF[LINE] | Do not skip files with offline attribute set. |
Remarks
The files that you want compare can have the same file name in different directories or on different drives.
How the comp command identifies mismatching information
comp displays messages to identify the locations of unequal information in the two files. Each message indicates the memory address of the unequal bytes and the contents of the bytes. Message appears in the following format:
Compare error at OFFSET xxxxxxxx
file1 = xx
file2 = xx
After 10 unequal comparisons, comp stops comparing the files and displays the following message:
10 Mismatches – ending compare
Comparing files of different sizes
You cannot compare files of different sizes unless you specify the /n command-line option.
Examples
To compare the contents of two directories C:\User with the backup directory \\Backup\User.
Comp c:\User \\backup\User
To compare the first ten lines of the text files in the \user directory and display the result in decimal format.
Comp \User\Data.txt \\backup\User\Data.txt /n=10 /d