fcFC Command Guide - Compare Files and Display Differences in Windows
Learn how to use the fc command to compare two files or sets of files and display differences in Windows Command Prompt. Includes syntax, binary/ASCII comparison, examples, and troubleshooting.
The fc command is a Windows Command Prompt utility that compares two files or sets of files and displays the differences between them. Use fc file1.txt file2.txt for ASCII text comparison showing line-by-line differences, or fc /b file1.exe file2.exe for binary comparison showing byte-by-byte differences. The command identifies additions, deletions, and modifications between file versions.
Whether you're verifying file integrity after transfers, comparing configuration files across systems, troubleshooting code changes, or validating backups, mastering fc provides essential file comparison capabilities without third-party tools. Developers and system administrators rely on this command for version control troubleshooting, configuration audits, and data validation in scripts and deployment processes.
This comprehensive guide covers fc syntax, ASCII vs. binary comparison modes, practical examples for different file types, output interpretation, automation strategies, troubleshooting tips, alternative comparison tools, related commands, and frequently asked questions. By the end, you'll confidently compare files from the command line for quality assurance, troubleshooting, and system administration tasks.
What Is the FC Command?
The fc command has been part of Windows (and MS-DOS before it) since the earliest versions, providing built-in file comparison capabilities. FC stands for "File Compare" and operates in two distinct modes:
- ASCII mode – Line-by-line comparison of text files with context around differences
- Binary mode – Byte-by-byte comparison of any file type with hexadecimal output
When to Use FC
FC is ideal for scenarios where you need to verify file identity or identify differences:
- Configuration management – Compare config files across servers or versions
- Version control troubleshooting – Verify what changed between file revisions
- Data validation – Confirm file integrity after network transfers or backups
- Code review – Quick diff of source files before/after changes
- Deployment verification – Ensure deployed files match source files
- Binary integrity – Verify executables, DLLs, or images are identical
- Log analysis – Compare log files to identify changes over time
The command works in Command Prompt (CMD), Windows PowerShell (with CMD compatibility), and is available in all modern Windows versions including Windows 11, Windows 10, Windows 8, Windows 7, and Windows Server editions.
System administrators and developers use fc in batch scripts, deployment automation, configuration audits, and troubleshooting workflows. While more sophisticated diff tools exist (Beyond Compare, WinMerge, git diff), fc's ubiquity and zero installation requirements make it invaluable for quick comparisons on any Windows system.
FC Command Syntax
The basic syntax for the fc command is:
fc [/a] [/b] [/c] [/l] [/lb n] [/n] [/t] [/u] [/w] [/nnnn] [drive1:][path1]file1 [drive2:][path2]file2
Parameters and File Specifications
| Parameter | Description |
|---|---|
file1 | First file or set of files to compare (required) |
file2 | Second file or set of files to compare (required) |
Both file specifications support full paths, relative paths, and wildcards. At least two files must be specified.
ASCII Mode Switches (Text Files)
| Switch | Description |
|---|---|
/a | Abbreviate output—show only first and last line of each difference block |
/c | Ignore case of letters during comparison |
/l | Compare files as ASCII text (default for .txt, .ini, .log, etc.) |
/lb n | Set maximum consecutive mismatches to n lines before aborting (default 100) |
/n | Display line numbers in ASCII comparison output |
/t | Do not expand tabs to spaces (preserve tab characters) |
/u | Compare files as Unicode text |
/w | Compress white space (tabs and spaces) for comparison |
/nnnn | Specify number of consecutive lines that must match after mismatch to resync |
Binary Mode Switches
| Switch | Description |
|---|---|
/b | Perform binary comparison (byte-by-byte) |
Binary mode compares files byte-by-byte and displays hexadecimal offsets where differences occur. Essential for executables, images, compressed files, and any non-text formats.
ASCII Text Comparison
Basic Text File Comparison
To compare two text files:
fc config1.txt config2.txt
Output:
Comparing files config1.txt and CONFIG2.TXT
***** config1.txt
line 5: server=prod-01.company.com
line 6: port=8080
***** CONFIG2.TXT
line 5: server=prod-02.company.com
line 6: port=9090
*****
FC displays context showing what's different. Lines with ***** indicate which file the following lines are from.
Comparison with Line Numbers
To see line numbers for easier reference:
fc /n file1.txt file2.txt
Output:
Comparing files file1.txt and file2.txt
***** file1.txt
5: old data here
6: more old data
***** file2.txt
5: new data here
6: more new data
*****
Line numbers help you locate differences in large files. Essential for troubleshooting configuration files and source code.
Case-Insensitive Comparison
To ignore case differences:
fc /c passwords.txt PASSWORDS.TXT
Useful when comparing files from different systems where filename or content case may vary but logical content should be identical.
Ignore White Space Differences
To compress white space (treat multiple spaces/tabs as single space):
fc /w formatted1.txt formatted2.txt
Compares logical content while ignoring formatting differences. Helpful for comparing files that have been reformatted with different indentation or spacing.
Abbreviated Output
For files with large difference blocks, show only first and last line:
fc /a /n largefile1.txt largefile2.txt
Abbreviated output reduces screen clutter when differences span many lines. Shows enough context to identify difference locations without overwhelming output.
Unicode Text Comparison
To compare Unicode text files:
fc /u unicode1.txt unicode2.txt
Handles Unicode encoding correctly. Use for comparing files with international characters, special symbols, or emoji.
Binary File Comparison
Basic Binary Comparison
To compare binary files byte-by-byte:
fc /b program.exe program_backup.exe
Output:
Comparing files program.exe and PROGRAM_BACKUP.EXE
FC: no differences encountered
If files are identical, fc reports no differences. If different, it shows hexadecimal offsets.
Binary Comparison with Differences
When binary files differ:
fc /b file1.dat file2.dat
Output:
Comparing files file1.dat and file2.dat
00000010: 4A 3C
00000011: 7F 8A
00000023: FF 00
Each line shows:
- Hexadecimal offset – Position in file where difference occurs
- First file byte – Hexadecimal value in first file
- Second file byte – Hexadecimal value in second file
Compare Executable Files
To verify two executables are identical:
fc /b C:\Program Files\App\program.exe C:\Backup\program.exe
Essential for verifying file integrity after copying, downloading, or restoring executables. Even one byte difference can indicate corruption or version mismatch.
Compare Image Files
To verify image file integrity:
fc /b original.jpg downloaded.jpg
Binary comparison confirms pixel-perfect identity. Useful after file transfers to verify no corruption occurred.
Compare Compressed Archives
To verify archive integrity:
fc /b backup.zip backup_copy.zip
Compressed files must be compared in binary mode. Byte-by-byte identity confirms perfect copy.
Comparing Multiple Files
Compare Files Using Wildcards
To compare all files matching a pattern:
fc *.txt backup\*.txt
Compares each .txt file in current directory with corresponding file in backup directory. FC automatically matches filenames and compares pairs.
Note: Both paths must contain matching filenames for comparison to occur.
Compare Directories
While fc doesn't have native directory comparison, you can combine with other commands:
for %f in (source\*.txt) do fc "source\%~nxf" "destination\%~nxf"
Iterates through files in source directory and compares each with destination. Useful for deployment verification.
Batch File Comparison Script
Create a batch script for comparing multiple file pairs:
@echo off
echo Comparing configuration files...
fc /n config\server1.cfg config\server2.cfg
echo.
fc /n config\database1.cfg config\database2.cfg
echo.
fc /n config\network1.cfg config\network2.cfg
echo.
echo Comparison complete.
Automate comparison of standard file sets. Integrate into deployment or audit workflows.
Interpreting FC Output
Successful Comparison (Identical Files)
When files match:
Comparing files file1.txt and file2.txt
FC: no differences encountered
Exit code 0 indicates files are identical. Scripts can check %ERRORLEVEL% to determine success.
Differences Found
When files differ, fc shows context:
***** file1.txt
line 10: old value
line 11: old setting
***** file2.txt
line 10: new value
line 11: new setting
*****
The ***** markers separate difference blocks. Context helps identify what changed.
Resync After Differences
FC continues comparing after finding differences, attempting to resynchronize:
***** file1.txt
line 10: different
***** file2.txt
line 10: also different
*****
***** file1.txt
line 50: another difference
***** file2.txt
line 50: another change
*****
Multiple difference blocks indicate several non-contiguous changes throughout the files.
Exit Codes
FC returns exit codes for script automation:
- 0 – Files are identical
- 1 – Files differ
- 2 – Error occurred (file not found, access denied, etc.)
Check exit code in scripts:
fc /b file1.dat file2.dat
if %ERRORLEVEL%==0 echo Files are identical
if %ERRORLEVEL%==1 echo Files differ
if %ERRORLEVEL%==2 echo Error comparing files
Common Use Cases
Verify File Transfer Integrity
Compare source and destination after network transfer:
fc /b C:\Source\database.bak \\FileServer\Backup\database.bak
Ensures transferred files are byte-for-byte identical. Critical for databases, executables, and compressed archives.
Compare Configuration Files Across Servers
Audit configuration consistency across infrastructure:
fc /n C:\Config\web.config \\WebServer2\C$\Config\web.config
Identify configuration drift between servers. Ensures consistent settings across load-balanced or redundant systems.
Code Review Before Deployment
Quickly review changes before deploying:
fc /n original\script.js modified\script.js
Spot check changes made to code files. Lightweight alternative to full version control diff when VCS isn't available.
Validate Backup Integrity
Verify backups match source files:
fc /b C:\Important\document.docx E:\Backup\document.docx
Confirms backup process didn't corrupt files. Run periodically to validate backup integrity.
Compare Log Files for Changes
Identify what changed in log files:
fc /n yesterday.log today.log
Spot new errors, warnings, or patterns in log data. Useful for troubleshooting when issues began.
Verify Software Deployment
Confirm deployed files match installation source:
fc /b "C:\Program Files\MyApp\app.exe" "\\DeploymentShare\MyApp\app.exe"
Ensures correct software version was deployed. Catches deployment errors early.
Compare Scripts Before Execution
Review script changes before running in production:
fc /n old_script.bat new_script.bat
Spot check modifications to batch files, PowerShell scripts, or SQL scripts before execution in critical environments.
Detect File Tampering
Verify files haven't been modified:
fc /b system32\original.dll system32\current.dll
Binary comparison detects unauthorized changes. Part of security auditing and intrusion detection.
Tips and Best Practices
Always Use Binary Mode for Non-Text Files
Text mode may misinterpret binary files and produce meaningless output. Use /b for executables, images, compressed files, databases, and any non-text format.
Use Line Numbers for Large Text Files
The /n switch makes it easier to locate differences in large files. Without line numbers, finding specific changes in thousand-line files is tedious.
Automate Comparisons in Scripts
Check fc exit codes (%ERRORLEVEL%) in batch scripts to automate validation. Exit code 0 = identical, 1 = different, 2 = error. Build deployment verification and backup validation scripts.
Combine with FOR Loops for Batch Comparison
Use FOR loops to compare multiple file pairs automatically. Essential for comparing entire directories or file sets in deployment verification.
Redirect Output to Files for Documentation
Capture fc output for audit trails:
fc /n config1.ini config2.ini > comparison_report.txt
Preserves comparison results for documentation, compliance, or troubleshooting reference.
Use /w for Comparing Reformatted Code
When comparing code that's been reformatted (different indentation, spacing), /w ignores white space differences and focuses on content changes.
Test on Small Files First
When learning fc or testing new comparison scripts, start with small test files. Understand output format before applying to large production files.
Consider Alternative Tools for Complex Diffs
FC is excellent for quick comparisons but lacks features like side-by-side view, syntax highlighting, or merge capabilities. For complex diff tasks, consider WinMerge, Beyond Compare, or git diff.
Use Case-Insensitive Mode Carefully
The /c switch can hide legitimate differences in case-sensitive contexts (Linux file paths, SQL object names, programming language keywords). Use only when case truly doesn't matter.
Verify Permissions Before Comparing Network Files
Ensure you have read access to both files, especially when comparing across network shares. Access denied errors return exit code 2.
Understand Resync Limitations
FC attempts to resynchronize after finding differences. Very different files may fail resynchronization, showing all remaining lines as different. For completely different files, consider alternative comparison methods.
Document Expected Differences
When comparing files that legitimately differ (production vs. development configs), document expected differences. Helps distinguish intentional from unintentional changes during audits.
Troubleshooting Common Issues
"Cannot Open File - No Such File or Directory"
Problem: FC fails with "cannot open" error for one or both files.
Cause: Incorrect file path, typo in filename, or file doesn't exist.
Solution:
- Verify file paths with
dir path\to\file - Check spelling of filenames carefully
- Use quotes for paths with spaces:
fc "path with spaces\file.txt" "other path\file.txt" - Verify current directory matches expected location
- Check file permissions—ensure read access
Prevention: Use tab completion for filenames; verify paths with dir before running fc.
"Access Is Denied"
Problem: FC fails with access denied error.
Cause: Insufficient permissions to read one or both files.
Solution:
- Run Command Prompt as Administrator
- Check file permissions with
icacls filename - Request access from system administrator if files are restricted
- Verify you're not trying to compare files locked by running applications
Prevention: Ensure appropriate file permissions before attempting comparison; close applications with files open.
Output Too Large to Read
Problem: FC output scrolls off screen for files with many differences.
Cause: Large files with extensive differences produce overwhelming output.
Solution:
- Redirect output to file:
fc file1.txt file2.txt > diff.txt - Pipe to
morefor paged output:fc file1.txt file2.txt | more - Use
/aabbreviated output for text comparisons - Consider alternative diff tools for complex comparisons
Prevention: Redirect large comparisons to files; use /a for abbreviated output.
FC Shows No Differences But Files Are Different
Problem: FC reports identical files when you know they differ.
Cause: Wrong comparison mode (text vs. binary), encoding issues, or white space compression.
Solution:
- Verify file sizes with
dir—different sizes prove files differ - Try binary mode:
fc /b file1.dat file2.dat - Check for Unicode encoding issues—try
/ufor Unicode files - Remove
/wif you used it—white space may be the difference - Verify you're comparing correct files (check timestamps with
dir)
Prevention: Choose correct comparison mode based on file type; use binary mode when uncertain.
Comparison Fails with "Resynch Failed"
Problem: FC reports "Resynch failed. Files are too different" error.
Cause: Files differ so extensively that FC can't resynchronize after finding differences.
Solution:
- Increase resync threshold:
fc /5000 file1.txt file2.txt(allow 5000 mismatches) - If files are completely different, fc may not be appropriate tool
- Consider using
/bbinary mode for byte-by-byte comparison - Try alternative diff tools (WinMerge, Beyond Compare) for heavily modified files
Prevention: Understand that fc works best for mostly similar files with localized differences; use other tools for comprehensive rewrites.
Binary Comparison Shows Too Many Differences
Problem: Binary comparison output is overwhelming with hundreds of byte differences.
Cause: Files are substantially different or completely unrelated.
Solution:
- Verify you're comparing correct files (check filenames and paths)
- Check file sizes with
dir—vastly different sizes indicate wrong files - If intentionally comparing different versions, consider text diff tools
- For executables/DLLs, version differences produce many byte changes
Prevention: Confirm file paths before comparing; understand that binary files show all byte-level differences.
Related Commands
comp – File Comparison
comp is an older, simpler file comparison utility. It performs binary comparison like fc /b but with less detailed output. FC is generally preferred for more informative output and additional options.
findstr – String Search
findstr searches for text patterns in files. Use findstr to locate specific content; use fc to compare entire files for differences. Complementary tools for file analysis.
robocopy – Robust File Copy
robocopy copies files and can compare source/destination. Use robocopy /l (list only) to see what would be copied without actually copying—similar to identifying file differences. FC verifies byte-level identity; robocopy handles bulk copy operations.
xcopy – Copy Files
xcopy has /d switch to copy only files newer than destination. Use xcopy for selective copying based on timestamps; use fc for exact content comparison regardless of timestamps.
icacls – NTFS Permissions
icacls manages file permissions. Before comparing files, use icacls to verify read permissions. After comparison identifies differences, icacls can modify permissions if needed.
attrib – File Attributes
attrib displays and modifies file attributes. Use attrib to check if files have different attributes (hidden, system, read-only) that might explain behavior differences beyond content comparison.
Frequently Asked Questions
What does fc file1.txt file2.txt do?
fc file1.txt file2.txt compares two text files and displays line-by-line differences. Output shows which lines differ between the files with context around changes. If files are identical, fc reports "no differences encountered."
What's the difference between fc and comp?
FC provides more detailed output with context around differences and supports both ASCII and binary modes with numerous options. COMP is an older, simpler utility with minimal output. FC is generally preferred for its flexibility and informative output.
How do I compare binary files?
Use fc /b file1.exe file2.exe for binary comparison. Binary mode compares files byte-by-byte and displays hexadecimal offsets where differences occur. Essential for executables, images, and any non-text formats.
Can fc compare entire directories?
No, fc doesn't have native directory comparison. However, you can use wildcards (fc *.txt backup\*.txt) or combine fc with FOR loops in batch scripts to compare multiple file pairs. For comprehensive directory comparison, consider robocopy or dedicated tools like WinMerge.
How do I ignore case differences?
Use fc /c file1.txt file2.txt to perform case-insensitive comparison. Treats uppercase and lowercase letters as equivalent. Useful when comparing files from different systems with case variations.
What does "FC: no differences encountered" mean?
This message indicates the two files are byte-for-byte identical. Exit code 0 is returned. Scripts can check this exit code to verify successful comparison and file identity.
How can I compare files on different servers?
Use UNC paths: fc C:\local\file.txt \\RemoteServer\Share\file.txt. Requires network access and appropriate permissions on remote server. Verify network connectivity and share permissions before attempting remote comparison.
Can I save fc output to a file?
Yes, redirect output: fc file1.txt file2.txt > comparison.txt. Captures comparison results for documentation, audit trails, or later review. Use >> to append to existing files instead of overwriting.
What exit codes does fc return?
FC returns 0 if files are identical, 1 if files differ, and 2 if an error occurred (file not found, access denied). Check %ERRORLEVEL% in batch scripts to automate validation workflows.
Why does fc show weird characters for binary files?
Running fc without /b on binary files attempts ASCII comparison, interpreting binary data as text. Result is garbled output. Always use /b for non-text files (executables, images, compressed files).
How do I compare Unicode files?
Use fc /u file1.txt file2.txt for Unicode text comparison. Handles international characters, special symbols, and emoji correctly. Without /u, Unicode characters may be misinterpreted.
Can fc merge files?
No, fc only compares and displays differences. It doesn't have merge capabilities. For merging different file versions, use dedicated merge tools (WinMerge, Beyond Compare) or version control systems (Git).
Quick Reference Card
| Command | Purpose | Example |
|---|---|---|
fc file1.txt file2.txt | ASCII text comparison | Compare config files |
fc /n file1.txt file2.txt | Compare with line numbers | Easier difference location |
fc /b file1.exe file2.exe | Binary comparison | Compare executables |
fc /c file1.txt file2.txt | Case-insensitive compare | Ignore case differences |
fc /w file1.txt file2.txt | Ignore white space | Compare reformatted code |
fc /a file1.txt file2.txt | Abbreviated output | Reduce output verbosity |
fc /u file1.txt file2.txt | Unicode comparison | International characters |
fc *.txt backup\*.txt | Compare multiple files | Batch comparison |
Try FC in Our Simulator
Want to practice using the fc command without affecting your system? Try our interactive Windows Command Simulator to experiment with file comparison operations in a safe, simulated environment. Practice comparison syntax, see simulated differences, and understand output formats before running commands on your actual system.
For more file management commands, browse our comprehensive Commands Reference with over 200 Windows commands, syntax guides, and practical examples.
Summary
The fc command provides essential file comparison capabilities built into every Windows system. By comparing files line-by-line in ASCII mode or byte-by-byte in binary mode, you can verify file integrity, identify configuration differences, troubleshoot code changes, and validate backups without third-party tools.
Key takeaways: Use fc file1.txt file2.txt for text file comparison with line-by-line differences. Apply fc /b file1.exe file2.exe for binary files requiring byte-by-byte verification. Include /n for line numbers in large text files, /c for case-insensitive comparison, and /w to ignore white space differences. Check exit codes (0 = identical, 1 = different, 2 = error) in scripts for automated validation.
FC excels at quick comparisons, verification tasks, and script automation but lacks advanced features like side-by-side views, syntax highlighting, or merge capabilities. For complex diff requirements, consider dedicated tools like WinMerge or Beyond Compare. However, fc's ubiquity and zero installation requirements make it invaluable for rapid verification on any Windows system.
For system administrators and developers, fc is essential for deployment verification, configuration auditing, backup validation, and troubleshooting file-related issues. Integrate fc into batch scripts, deployment pipelines, and maintenance workflows to automate file comparison and catch discrepancies early.
Master the fc command to verify file integrity, compare configurations, troubleshoot changes, and validate deployments—all through command-line automation and scripting capabilities available on every Windows installation.