命令行大全

comp

嚯嚯 发表于 2020-06-29 13:52浏览次数:

该comp命令允许用户比较两个文件或两个文件集的内容。

查看英文版

目录:

1 comp 运行系统环境

2 comp 语法

3 comp 示例

comp 运行系统环境

Windows xp

Windows vista

Windows 2000

Windows 7

Windows 8

Windows 10

MS-DOS 2.x - 5.x

comp 语法

比较两个文件或文件集的内容。

COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C]
data1 指定要比较的第一个文件的位置和名称。
data2 指定要比较的第二个文件的位置和名称。
/D 以十进制格式显示差异。
/A 显示ASCII字符的差异。
/L 显示行号差异。
/N=number 仅比较每个文件中第一个指定的行数。
/C 比较文件时忽略ASCII字母的大小写。

要比较文件集,请在data1和data2参数中使用通配符。

Compares the contents of two files or sets of files.

COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C]
data1 Specifies location and name(s) of first file(s) to compare.
data2 Specifies location and name(s) of second files to compare.
/D Displays differences in decimal format.
/A Displays differences in ASCII characters.
/L Displays line numbers for differences.
/N=number Compares only the first specified number of lines in each file.
/C Disregards case of ASCII letters when comparing files.

To compare sets of files, use wildcards in data1 and data2 parameters.

查看英文版

查看中文版

comp 示例

comp file1.txt file2.txt /N=10 /A

比较file1.txt和file2.txt。在此示例中,我们使用/ A选项显示比较发现不同的ASCII 字符。如果未显示/ A选项,则comp命令将以十六进制表示法显示差异。以下是此示例中comp命令如何显示比较的示例。

Compare error at LINE 5
file1 = i
file2 = o
Compare error at LINE 5
file1 = v
file2 = u
Compare error at LINE 5
file1 = e
file2 = r
Compare error at LINE 6
file1 = s
file2 = f
Compare error at LINE 6
file1 = x
file2 = v
Compare error at LINE 6
file1 =
file2 = e
Compare error at LINE 7
file1 =
file2 =
Compare error at LINE 7
file1 =
file2 =
Compare error at LINE 8
file1 =
file2 = s
File1 only has 7 lines
comp file1.txt file2.txt /N=10 /A

Compares file1.txt with file2.txt. In this example, we are using the /A option to display the ASCII characters that the compare has found different. If the /A option is not displayed, the comp command displays the differences in hexadecimal notation. Below is an example of how the comp command may display the comparison in this example.

Compare error at LINE 5
file1 = i
file2 = o
Compare error at LINE 5
file1 = v
file2 = u
Compare error at LINE 5
file1 = e
file2 = r
Compare error at LINE 6
file1 = s
file2 = f
Compare error at LINE 6
file1 = x
file2 = v
Compare error at LINE 6
file1 =
file2 = e
Compare error at LINE 7
file1 =
file2 =
Compare error at LINE 7
file1 =
file2 =
Compare error at LINE 8
file1 =
file2 = s
File1 only has 7 lines

除非使用/ N选项,否则comp命令仅比较文件的大小。

Unless the /N option is used the comp command only compares the size of the file.

查看英文版

查看中文版