Comp
Compare the content of two files or several groups of files. Comp can compare files on the same drive or different drives and files in the same directory or different directories. When you compare a file with comp, it displays the file location and file name. If this parameter is not included, the comp prompts you to enter the file to be compared.
Syntax
Comp [data1] [data2] [/d] [/a] [/l] [/n = number] [/c]
Parameters
Data1
Specifies the location and name of the first file or file set to be compared. Use wildcard characters (* And ?) You can specify multiple files.
Data2
Specifies the location and name of the Second file or file set to be compared. Use wildcard characters (* And ?) You can specify multiple files.
/D
Display the difference in decimal format. (The default format is hexadecimal .)
/
Display the differences as characters.
/L
Displays the number of rows with different values, instead of the number of bytes.
/N = number
Compare the first number of two files, even if the sizes of the two files are different.
/C
Perform case-insensitive comparison.
/?
Display help at the command prompt.
Note
Compare objects with the same name
If the files to be compared are in different directories or different drives, they can have the same file name. If the file name is not specified for data2, the default file name of data2 is the same as that of data1. Wildcard characters (* And?) can be used ?) To specify the file name.
Special circumstances of data1 and data2
If necessary components of data1 or data2 are omitted or data2 is omitted, comp prompts you to enter the missing information. If data1 only contains a drive letter or a directory name without a file name, comp compares all files in the specified directory with the files specified in data2. If data2 only contains the drive letter or directory name, the default file name of data2 is the same as that in data1.
How to identify unmatched information using the comp command
During the comparison, the comp displays a message that identifies the location of different information in the two files. Each message indicates an unequal byte offset memory address and the content of the byte (unless/a or/d command line is specified, it is expressed in hexadecimal notation ). Messages are displayed in the following format:
Compare error at OFFSET xxxxxxxx
File1 = xx
File2 = xx
After 10 unequal comparisons, the comp command terminates the file comparison and displays the following information:
10 Mismatches-ending compare
Comparing files of different sizes
Files of different sizes cannot be compared unless the/n command line option is specified. If the file size is different, the following message is displayed:
Files are different sizes
Compare more files (Y/N )?
Compare other file pairs by Y. Press N to stop the comp command.
If you press Y to respond to the prompt, in each comparison, comp uses any command line option specified in the command line until you press N or re-type the command.
When comparing files of different sizes, use the/n command line option to compare only the first part of each file.
Compare files in order
If wildcard characters (* And?) are used ?) When multiple files are specified, comp searches for the first file that matches data1 and compares it with the corresponding file (if any) in data2. The comp Command reports the comparison results and then performs the same operation on each file that matches data1. After completion, the comp displays the following messages:
Compare more files (Y/N )?
To compare other files, Press Y. Enter the location and name of the new file at the comp command prompt. To stop the comparison, press N. When you press Y, comp prompts you to enter the command line option to use. If no command line option is specified, comp uses the previously specified command line option.
If the comp file cannot be found
If the specified file cannot be found in comp, a message is displayed, prompting you to determine whether to compare other files.
Example
To compare the contents of directory C: \ Reports with the Backup directory \ Sales \ Backup \ Volume l, type:
Comp c: \ reports \ sales \ backup \ CMDL
To compare the first 10 lines of text files in the \ Invoice directory and display the results in decimal format, type:
Comp \ invoice \ *. txt \ invoice \ backup \ *. txt/n = 10/d
XOX