Compares the contents of two files or groups of files byte by byte. Comp You can compare files on the same or different drives and files in the same or different directories. comp When comparing files, it displays the location and name of the file. If used without parameters, then comp Prompt for files to compare.
comp [data1] [data2] [/d] [/a] [/l] [/n=number] [/c]
Specifies the location and name of the first file or file set to compare. Use the wildcard (* and ?） You can specify multiple files.
Specifies the location and name of the second file or file set to compare. Use the wildcard (* and ?） You can specify multiple files.
Displays the difference in decimal format（ The default format is hexadecimal.)
Displays the difference as a character.
Displays the line number where the difference occurs, not the byte offset.
Compare the first of two files Number, even if the two files are not the same size.
Performs a case insensitive comparison.
Display help at the command prompt.
Compare files with the same name
If the files to be compared are located in different directories or different drives, they can have the same file name. If not data2 If you specify a file name, the data2 The default file name of the data1 The file names in are the same. You can use the wildcard (* and ?） To specify the file name.
data1 and data2 Special circumstances of
If omitted data1 or data2 Necessary components or omissions of data2，comp You will be prompted for the missing information. If data1 A directory name that contains only a drive letter or no file name comp All files and data2 File specified in. If data2 Contains only the drive letter or directory name data2 The default file name of the data1 The same as in.
comp How do commands identify mismatches
During the comparison, comp A message is displayed identifying the location of different information in the two files. Each message indicates the offset memory address of unequal bytes and the content of the byte itself (unless specified) / a or / d Command line options, otherwise all in hexadecimal notation). The message is displayed in the following format:
Compare error at OFFSET xxxxxxxx
file1 = xx
file2 = xx
after ten After an unequal comparison, comp The command terminates the file comparison and displays the following information:
10 Mismatches – ending compare
Comparing files of different sizes
Unless specified / n Command line options, otherwise files of different sizes cannot be compared. If the file size is different, comp The following message is displayed:
Files are different sizes
Compare more files (Y/N)?
Press Y Compare other file pairs. Press N stop it comp Orders.
If you press Y In response to the prompt, the comp In each comparison it makes, any of the command line options specified on the command line are used until you press N Or retype the command.
When comparing files of different sizes, use / n The command line option compares only the first part of each file.
Compare files in order
If you use a wildcard (* and ?） Specify multiple files, comp Find and data1 Match the first file and match it with the data2 Compare with the corresponding files (if any) in. comp The command reports the results of the comparison, and then compares the results for each match data1 Do the same for the file. When finished, comp The following message is displayed:
Compare more files (Y/N)?
To compare other files, press Y。 comp Command prompt you type the location and name of the new file. To stop comparing, press N。 When pressed Y Comp You are prompted for command line options to use. If no command line options are specified, comp The previously specified command line options are used.
If comp cannot find file
If comp Unable to find the specified file, you will be prompted with a message to decide whether to compare other files.
To add a directory C:\Reports Content and backup directory of \\ Sales\Backup\April To compare, type:
comp c:\reports \\sales\backup\april
To compare \ Invoice The beginning of a text file in a directory ten To display the result in decimal format, type:
comp \invoice\*.txt \invoice\backup\*.txt /n=10 /d