Windows OS

What is the Windows Equivalent of the diff Command?

diff” is a command-line tool used for comparison in Unix and Linux. This command compares the contents of a directory’s file with other specified files. The Windows equivalent of the diff command is the “FC” utility that is also used for comparison purposes.

This write-up will discuss what diff command is and what is the Windows equivalent of it. So, let’s begin!

What is diff Command?

The diff command is a Linux command that compares the content of the specified files by line and displays the results. Along with that, it also provides options as suggestions. If the diff function returns an option “a”, it implies that it advises adding a line; if it returns “c”, it means that it suggests changing the text, and if it returns “d”, it suggests deleting the line to produce an exact match.

How to Use diff Command on Windows?

The diff command can not be directly used on the Windows Command line as it requires installing the “diffutils” package on Windows. After installing the diffutils package, you can use the diff command to compare two files as follows:

>diff -w File1.txt File2.txt

What is the Windows Equivalent of the diff Command?

The Windows command that is equivalent to the diff is the “FC”. The “FC” stands for “File Comparison”. It is a built-in command utility used to compare files and returns their output.

Check out some examples to go through the “FC” command usage on Windows.

Example 1: Use FC Command to Compare Same Files

Let’s see how to compare files using the FC command. To investigate the FC command output, we have compared File1.txt by itself:

>FC File1.txt File1.txt

The below-given output indicates that no differences are found among the specified files.

Example 2: Use FC Command to Compare Different Files

Utilize FC to compare two different files “File.txt” with “File1.txt”:

>FC File.txt File1.txt

Example 3: Use FC Command to Compare Files Using ASCII Option

Specify the “/L” option to check comparison of files in ASCII mode:

>FC /L File1.txt File1.txt

Example 4: Use FC Command to Compare Using Unicode Option

Utilize “/U” option to make a comparison for the specified file using Unicode:

>FC /U File1.txt File1.txt

Example 5: Use FC Command to Compare Files Using Binary Option

Now, use FC command with “/B” option to compare file content in binary form:

>FC /B File1.txt File1.txt

Example 6: Use FC Command to Compare All Files with a Specific File

To compare a text file with all files “*.txt” that are currently placed in the opened directory, utilize below-provided FC command:

>FC *.txt File1.txt

Note: Here “*” asterisk represents all files with the specific extension.

We have offered the Windows Equivalent of the diff Command.

Conclusion

The Windows equivalent of the diff command is an “FC” utility, primarily used to compare files as the Linux diff command. To use the FC command, first, open the command prompt by searching “CMD” in the “Startup” menu. Then, compare the files on Command Prompt by utilizing the “FC first_file_name.txt second_file_name.txt” command. We have elaborated on “FC” as the Windows equivalent of the diff Command in this article.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.