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.