Comp compares the contents of two files or groups of files by byte _dos/bat

Source: Internet
Author: User
Comp
Compares the contents of two files or groups of files by byte. Comp can compare files on the same drive or on different drives and files in the same directory or in different directories. When comp compares a file, it displays the location and file name of the file. If used without parameters, Comp prompts for the file to be compared.

Grammar
comp [data1] [data2] [/d] [/a] [/l] [/n=number] [/c]

Parameters
Data1
Specifies the location and name of the first file or set of files to compare. Use wildcard characters (* and?) to specify multiple files.
Data2
Specifies the location and name of the second file or set of files to compare. Use wildcard characters (* and?) to specify multiple files.
/d
Displays the difference in decimal format. (The default format is 16-in.) )
/A
Displays the difference as a character form.
/L
Displays the number of lines that appear differently, not the byte offsets.
/n=number
Compares the first number of two files, even if the size of two files is not the same.
/C
Performs a case-insensitive comparison.
/?
Display Help at the command prompt.
Comments
Compare files with the same name
If the files you want to compare are in different directories or different drives, they can have the same file name. If you do not specify a filename for data2, the default file name for the data2 is the same as the file name in Data1. You can use the wildcard character (* and?) to specify the file name.

Special cases of data1 and data2
If you omit the necessary components for data1 or data2 or omit Data2,comp, you will be prompted to enter the missing information. If Data1 contains only the drive letter or directory name without a filename, comp compares all files in the specified directory with the files specified in Data2. If DATA2 contains only drive letters or directory names, the default file name for Data2 is the same as in Data1.

How the comp command identifies mismatched information
During the comparison, comp displays a message that identifies the location of the different information in the two files. Each message indicates the offset memory address of an unequal byte and the contents of the byte itself (unless the/A or/d command-line option is specified), it is represented by the 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 contrast and displays the following information:

Ten mismatches-ending Compare

Comparing files of different sizes
You cannot compare files of different sizes unless you specify the/n command-line option. If the file size is different, comp displays the following message:

Files are different sizes

Compare more files (y/n)?

Press Y to compare other file pairs. Press N to stop the comp command.

If you press Y to respond to a hint, comp will use any command-line options specified on the command line in each comparison that you make, until you press N or retype the command.

When comparing files of different sizes, using the/n command-line option will only compare the first part of each file.

Compare files in order
If you use wildcards (* and?) to specify multiple files, comp finds the first file that matches data1 and compares it to the corresponding file in Data2, if any. The comp command reports the results of the comparison and then does the same for each file that matches data1. When finished, comp displays the following message:

Compare more files (y/n)?

To compare other files, press Y. At the comp command prompt, you type the location and name of the new file. To stop the comparison, press N. When you press Y, Comp prompts you to enter the command-line options you want to use. If you do not specify any command-line options, comp will use the command-line options that you specified earlier.

If comp cannot find the file
If comp cannot find the specified file, a message prompts you to decide whether you want to compare other files.

Example
To compare the contents of the directory C:\Reports to the backup directory \\Sales\Backup\April, type:

Comp C:\Reports \\sales\backup\april

To compare the first 10 lines of a text file in the \invoice directory and display the results in decimal format, type:

Comp \invoice\*.txt \invoice\backup\*.txt/n=10/d

XOX

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.