如果您正在寻找一种在没有任何第三方程序的情况下在Windows 10/11在本指南中,我们将向您展示如何使用Windows 10/11 上的命令提示符比较两个文件的更改。(compare two files for changes with Command Prompt)
您可以使用fc.exe和comp.exe文件比较命令比较两个文件。您可以使用 fc.exe 逐行比较两个ASCII或二进制文件。windiff.exe实用程序,该工具以图形方式比较两个ASCII文件的内容,或两个包含ASCII文件的文件夹的内容,以验证它们是否相同。
如果您想了解两个相似文件如何随时间发生变化, Windows(Windows)上有一个内置命令可以让您进行比较。该命令是fc
. 此命令可用于比较两个文本文件并了解它们在其脚本及其修改中的更改方式。使用“ fc ”命令,您可以将文本文件与其最新版本进行比较,或者在不同的脚本(如Binary、Unicode或ASCII )中查找脚本级别的更改。让我们看看我们如何使用“fc”命令并在Windows 10/11命令提示符比较两个(Command Prompt)文件(Files)的更改。
(Compare two) 使用FC.exe命令行比较两个文件(Files)的更改(Changes)
fc命令中有不同的参数,您可以在命令提示符(Command Prompt)中输入语法后使用它来实现不同的结果。
参数(Parameters)
意义(Meaning)
以二进制模式逐字节比较两个文件,并在发现不匹配后不尝试重新同步文件。
忽略字母大小写。
逐行比较ASCII模式的文件,并在发现不匹配后尝试重新同步文件。(ASCII)
/磅<n>
将内部行缓冲区的行数设置为 N。行缓冲区的默认长度为 100 行。如果您正在比较的文件有超过 100 个连续的不同行, fc 将取消比较。
在ASCII(ASCII)比较期间显示行号。
防止 fc 将制表符转换为空格。
将文件作为Unicode文本文件进行比较。
在比较期间压缩(Compresses)空白(即制表符和空格)。如果一行包含许多连续的空格或制表符, /w 将这些字符视为一个空格。当与 /w一起使用时, fc 会忽略行首和行尾的空白。
How to compare two Files for changes using Command Prompt
If you are searching for a way to compare two files on Windows 10/11 without any third-party program, we have a way for you. In this guide, we show you how you сan compare two files for changes with Command Prompt on Windows 10/11.
You can compare two files using the fc.exe and the comp.exe file compare commands. You can use fc.exe to compare two ASCII or binary files on a line-by-line basis. windiff.exe utility, a tool that graphically compares the contents of two ASCII files, or the contents of two folders that contain ASCII files, to verify whether they are the same.
If you want to find how two similar files have undergone changes over time, there is a built-in command on Windows that lets you compare. That command is fc
. This command is useful in comparing two text files and know how they are changed in its script and its modifications. With ‘fc‘ command, you can compare a text file with its latest version or find changes at the script level in different scripts like Binary, Unicode, or ASCII. Let’s see how we can use ‘fc’ command and compare two Files for changes With Command Prompt on Windows 10/11.
Compare two Files for Changes using FC.exe command-line
There are different parameters in fc command which you can use it to achieve different result after entering the syntax in Command Prompt.
Parameters
Meaning
/aThe parameter displays only the first and last line for each set of differences
/b
Compares the two files in binary mode, byte by byte, and does not attempt to resynchronize the files after finding a mismatch.
/c
Ignores the letter case.
/l
Compares the files in ASCII mode, line-by-line, and attempts to resynchronize the files after finding a mismatch.
/lb<n>
Sets the number of lines for the internal line buffer to N. The default length of the line buffer is 100 lines. If the files that you are comparing have more than 100 consecutive differing lines, fc cancels the comparison.
/n
Displays the line numbers during an ASCII comparison.
/off[line]Doesn’t skip files that have the offline attribute set.
/t
Prevents fc from converting tabs to spaces.
/u
Compares files as Unicode text files.
/w
Compresses white space (that is, tabs and spaces) during the comparison. If a line contains many consecutive spaces or tabs, /w treats these characters as a single space. When used with /w, fc ignores white space at the beginning and end of a line.
/
Specifies the number of consecutive lines that must match following a mismatch, before fc considers the files to be resynchronized.
[:][<path1>]
<filename1>
Specifies the location and name of the first file or set of files to compare. filename1 is required.
[:][<path2>]
<filename2>
Specifies the location and name of the second file or set of files to compare. filename2 is required.
/?
Displays help at the command prompt.
Usage of the fc command
How do I compare two files in Windows?
You can use fc command to compare two text files for changes or use the windiff.exe utility that comes with the Windows installation. The tool helps you graphically compare the contents of two ASCII files, or the contents of two folders that contain ASCII files, to verify if they are the same or not. You can also compare two text files in Windows using fc command. It has different parameters to do different types of comparisons.
1] If you want to compare two files names June and July in ASCII format and display the result in an abbreviated format, you can use:
fc /a june.rpt july.rpt
2] If you want to make a binary comparison of two bat files named June and July, use the following syntax:
fc /b june.bat july.bat
3] If you want to compare every bat file in a directory with July.bat file, use the following syntax:
fc *.bat july.bat
4] If you want to compare July.bat file on C drive with July.bat file on D drive, you can use:
fc c:july.bat d:*.bat
5] If you want to compare each batch file in the root directory on drive C to the file with the same name in the root directory on drive D, you can use:
fc c:*.bat d:*.bat
These are some of the commonly usable syntax using fc command in Command Prompt. You need to understand the parameters perfectly and write your own syntax if you have special requirements. Microsoft has some detailed explanations of some regularly used fc commands.
Related Read: Useful Commands to Manage Files and Folders using Command Prompt.