Comp command in Windows
The comp command compares the content of two files or gathers files in bytes. If used without parameters, the comp command will prompt you to enter files for comparison.
The comp command compares the content of two files or gathers files in bytes. If used without parameters, the comp command will prompt you to enter files for comparison.
For an example of how to use this command, please see the Example below.
Comp command in Windows
- Syntax comp command
- Parameters
- Note
- For example
Syntax comp command
comp [] [] [/d] [/a] [/l] [/n=] [/c]
Parameters
ParametersDescription Specifies the location and name of the file or the first set of files you want to compare. You can use wildcards ( * and ? ) To specify multiple files. Specify the location and name of the file or the second set of files you want to compare. You can use wildcards ( * and ? ) To specify multiple files. / d Display differences in decimal format. (The default format is hexadecimal). / a Displays differences in characters. / l Displays the number of lines where there is a difference, instead of displaying the byte deviation. / n = Compare only the number of lines specified for each file, even if the files are of different sizes. / c Make comparisons case sensitive. / off [line] Handle files with offline properties set. /? Show help at the command prompt.Note
- The comp command determines which information does not match
In comparison, the comp command displays messages that determine the location of information that is not the same between files. Each message indicates the offset memory address of the unequal byte and the contents of the bytes (in hexadecimal notation, unless the command line parameter / a or / d is specified). The message appears in the following format:
Compare error at OFFSET xxxxxxxx
file1 = xx
file2 = xx
After 10 unmatched comparisons, the comp command will stop comparing files and display the following message:
10 Mismatches - ending compare
- Handle special cases for Data1 and Data2
- If you omit the necessary components of Data1 or Data2 or if you omit Data2, the comp command will prompt you for the missing information.
- If Data1 contains only the drive letter or directory name, without the file name, the comp command compares all the files in the specified directory with the file specified in Data1.
- If Data2 contains only one drive letter or directory name, the default file name for Data2 is the same as in Data1.
- If the comp command cannot find the file (s) you specify, it will prompt you with a message to determine if you want to compare other files.
- Compare files in different locations
The comp command can compare files on the same drive or on different drives, and in the same folder or in different folders. When comparing files, it displays their location and file name.
- Compare files with the same name
The files you compare may have the same file name, as long as they are in different folders or on different drives. If you do not specify the file name for Data2, the default file name for Data2 is the same as the file name in Data1. You can use wildcards ( * and ? ) To specify the file name.
- Compare files of different sizes
You must specify the / n parameter to compare files of different sizes. If the file size is different and the / n parameter is not specified, the comp command will display the following message:
Files are different sizes
Compare more files (Y/N)?
To compare these files, press N to stop the comp command. Then, run the comp command with the / n option to compare only the beginning of each file.
- Compare sequential files
If you use wildcards ( * and ? ) To specify multiple files, the comp command will find the first file that matches Data1 and compare the file with the corresponding file in Data2, if it exists. The comp command reports the comparison results for each file that matches Data1. When completed, the comp command displays the following message:
Compare more files (Y/N)?
To compare other files, press Y. The comp command will prompt you for the location and name of the new file. To stop comparing, press N. When you press Y , the comp command will prompt you for command line options to use. If you do not specify any command line options, the comp command will use the options you specified earlier.
For example
To compare the contents of the C: Reports folder with the SalesBackupApril backup folder, enter:
comp c:reports salesbackupapril
To compare the first 10 lines of text files in the Invoice folder and display the results in decimal format, enter:
comp invoice*.txt invoicebackup*.txt /n=10 /d
See more:
- Cmdkey command in Windows
- The cipher command in Windows
- Choice command in Windows
You should read it
Maybe you are interested
How to avoid injury when using a PC How to use Photoshop CS5 - Part 15: Remove wrinkles with the Healing Brush tool 10 tips to help you become beautiful without make-up There was a year when the Earth had no summer and the world history was changed 10 types of food enhance men's vitality Surgery can permanently change your eye color to blue