Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Comp command in dos

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to use the Comp command in dos. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Comp

Compare the contents of two files or groups of files byte by byte. Comp can compare files on the same drive or different drives as well as files in the same or different directories. When comp compares files, it displays the location and file name of the file. If used without parameters, comp prompts for the file to compare.

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. Multiple files can be specified using wildcard characters (* and?).

Data2

Specify the location and name of the second file or set of files to compare. Multiple files can be specified using wildcard characters (* and?).

/ d

Display the differences in decimal format. (default format is hexadecimal. )

/ a

Displays the differences as characters.

/ l

Displays a different line number instead of a byte offset.

/ n=number

Compare the first number of two files, even if the two files are not the same size.

/ c

Performs a case-insensitive comparison.

/?

Displays help at the command prompt.

Annotation

Compare files with the same name

If the files you want to compare are in different directories or on different drives, they can have the same file name. If you do not specify a file name for data2, the default file name for data2 is the same as the file name in data1. You can use wildcard characters (* and?) to specify a file name.

Special case of data1 and data2

If you omit the necessary components of data1 or data2 or data2,comp, you will be prompted for missing information. If data1 contains only 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 contains only a drive letter or directory name, the default file name for data2 is the same as in data1.

How the comp command identifies mismatch information

During the comparison, comp displays a message identifying the location of different information in the two files. Each message indicates the offset memory address of the unequal bytes and the contents of the bytes themselves (expressed in hexadecimal notation unless the / an or / d command line options are specified). 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, comp displays the following message:

Files are different sizes

Compare more files (Y big N)?

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

If you press Y to respond to the prompt, comp uses any command line option specified on the command line in each comparison it makes until you press N or retype the command.

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

Compare files sequentially

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

Compare more files (Y big 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 for the command line options you want to use. If no command line options are specified, comp uses the previously specified command line options.

If comp can't find the file,

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

Example

To compare the contents of the directory C:\ Reports with 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 / nasty 10 / d

This is the end of this article on "how to use Comp commands in dos". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report