DIFF tool

does WIn10 have a built-in file compare command line utility the emits the same output format as Unix Diff command?

FC.EXE doesn’t create an “edit script” or at least not in the same format.

If there isn’t one built in, is there a “Free” one. my app needs to be able to call such a program from a Shell.
I have it working just find in macOS, but it has the Unix Diff as part of the OS already

WinMerge ?

WinMerge

WinMerge is neither built-in nor a command line utility… :frowning:

I need the edit script output as created by the Unix Diff command… no GUI required or desired…

Gotcha

You can call it from the command line but I understand you don’t want customers to have to install it

Maybe the Windows subsystem for Linux? course that is Windows 10 x64 only and is a Windows feature install add on

Dont really know what kind of output you need, but :

https://ss64.com/nt/comp.html

This is a powershell command:
diff (cat file1) (cat file2)

… does that work in Shell?

[quote=440553:@Jeff Tullin]Dont really know what kind of output you need, but :

https://ss64.com/nt/comp.html

This is a powershell command:
diff (cat file1) (cat file2)

… does that work in Shell?[/quote]

Win10 doesn’t have the “DIFF” command… seems to only have “FC” built in

required output is an “edit script”

COMP seems to compare character by character not “lines”… and the output is not an “edit script”

If you can call powershell this might help.

https://serverfault.com/questions/5598/how-do-i-diff-two-text-files-in-windows-powershell

The findstr command should be close. Here is an example of the command for comparing two text files:

findstr /v /g:"test.txt" "test1.txt"

test.txt contains this in the file:

My First Text. Line2 My Line 3

test1.txt contains this in the file:

My First Text. Line2 My Line 3 Line 4

When I run the findstr line above, the output is:

Line 4

Does this help Dave? If I missed it, then maybe create a simple example of Diff and I’ll see what I can do :slight_smile:

The major criteria is the the output MUST be identical to what the macOS/Unix/Linux DIFF command produces

[quote=440574:@Tanner Lee]If you can call powershell this might help.

https://serverfault.com/questions/5598/how-do-i-diff-two-text-files-in-windows-powershell[/quote]

no idea what or how “powershell” is different from the Windows Command line… :frowning:

you might need to ship a helper app to do this
or build one into whatever it is you’re making

Windows doesnt have such a tool built in as far as I know
at least not one that gives the same output as Unix diff

Yeah, that is what is seems …

I would have preferred to do the whole thing in pure Xojo code… but the Diff process is a bit complex especially when you start applying various compare criteria

it is
best I can figure is you use FC with one of the gazillion options it has that gets you kind of close to diff-like and then do some extra leg work on Windows
or write one (which is admittedly a decent sized job)

I’m sure you already read
https://stackoverflow.com/questions/6877238/what-is-the-windows-equivalent-of-the-diff-command
which asks almost this exact question

part way through one fellow points out that you can get fc to be “sort of diff-like” but that it wont be the same as diff

it seems even on that thread the conclusion is there is nothing built in

It’s just an alternative command interpreter from Microsoft. It’s built into Windows 10. More info here: https://docs.microsoft.com/en-us/powershell/

Some other options here for standalone compiles of various Unix tools (including diff utils) for DOS/Windows: Tiny Unix Tools for Windows

PowerShell is radically different to the old Window/DOS command line.

Use GNUWin32 (http://gnuwin32.sourceforge.net/) for Unix-like command line tools on Windows.

MinGW does not include a diff tool (at least my install of MinGW doesn’t).
Cygwin is an almost complete Linux sub-system but you cannot use the tools from a Windows command line (not easily anyway).
Windows Subsystem for Linux (WSL) is the Unix tool of choice for Windows but cannot be used from the standard command line.

Maybe I’m misunderstanding what you’re trying to accomplish Dave, but what about KDiff3 ? Although it’s an older program, and I’ve only used the GUI aspects of KDiff3, it still works fine on Windows 10 and it does appear to have some command-line options including an arguments for specifying an output file. See documentation

I hope that helps.

Thanks Scott… but I need only the “edit script” output exactly like the Unix DIFF command creates (see above post for a description of the 3 output formats (add/delete/change). I could have sworn there was such a tool in an older version of Windows, but seems I am mistaken.

FC doesn’t do it
COMPARE-OBJECTS doens’t do it

I was hoping for purposes of completeness to have my app work XPlat, but looks like it would require the user to install something additional.

You need to look at MinGW and see about building a Win32 verison of their diff tool for windows. This really is the only way to get a compatible diff for Windows.