To compare two text files on a Mac before combining edits, first make separate copies of both versions, then inspect their differences with Terminal’s diff command or a visual comparison tool such as Visual Studio Code or BBEdit. The comparison shows what changed; you still need to decide which edits to keep and save the merged result as a new file until you have checked it.
Prepare the two versions
Put both files somewhere easy to find, such as the Desktop or a temporary folder. Confirm which is the earlier or base version and which contains the newer edits. If both files have changed independently, note that neither one necessarily represents the right final version.
Before merging, duplicate the originals in Finder or use File > Duplicate in an app that supports it. Give the copies clear names, such as draft-original.txt, draft-edited.txt, and later draft-merged.txt. This gives you a way back if you overwrite content by mistake. Check that both files are plain text and that you are comparing the intended pair; formatted documents may contain structure that a plain text comparison does not represent.
Compare files in Terminal with diff
For a quick comparison using macOS’s command line, open Terminal and type diff -u , leaving a space after the command. Drag the first file from Finder into the Terminal window, type a space, drag the second file in, then press Return. The command compares the two file contents and prints a unified difference with surrounding context. The first path is the starting version; the second is the version being compared against it. Apple’s diff manual page documents the command and its unified output option.
diff -u /path/to/first.txt /path/to/second.txt
In the output, lines beginning with - appear in the first file but not the second; lines beginning with + appear in the second but not the first. Lines without either marker are context. A header beginning with @@ identifies the approximate line range for a changed section. If Terminal prints no difference output, the files compare as identical. A result that says the files differ without showing readable lines can mean the inputs are not being treated as ordinary text.
This output is a review aid, not a merged document. Do not paste the diff markers into your final file. Read each changed block in context, decide what belongs in the combined version, then edit a copy in a text editor and save it under a new name. If the files have many overlapping edits, a visual diff editor is usually easier to review.
Use a visual comparison for easier review
In Visual Studio Code, open one file, then use the Command Palette and choose File: Compare Active File With... to select the other. Alternatively, in the Explorer, right-click one file and choose Select for Compare, then right-click the other and choose Compare with Selected. VS Code displays a diff editor for reviewing changes. Its documentation also describes comparing the active file with the saved version or clipboard. Visual Studio Code’s file comparison instructions list these options.
BBEdit provides another Mac-oriented route: choose Search > Find Differences, supply the two files in the comparison window, and start the comparison. Its current comparison chart lists file comparison and character-level difference display among its features. BBEdit’s feature comparison chart describes the available Find Differences capability.
Whichever app you use, inspect the comparison from beginning to end. Similar blocks of text may shift around when lines are added or deleted, so do not assume a visually adjacent change belongs to the same edit. Also check punctuation, blank lines, spelling, and repeated sections: small differences can alter meaning or formatting.
Merge deliberately and verify the saved result
Work through each change and choose whether to keep the first version, the second, or a combination. When both files change the same sentence or paragraph, read both edits alongside the surrounding text and resolve them yourself. A two-file comparison identifies differences; it cannot tell which independently edited version expresses the intended final meaning.
Save the combined text to a third file. Then reopen that saved file and scan the areas you changed. If you want to confirm that it matches one source exactly, compare the saved result with that source using the same tool. Keep the originals until you are satisfied with the result.
This workflow is for two text files. A visual diff is not necessarily a three-way merge: when two people edited a shared base, you may also need that base version to distinguish independent additions from conflicting edits. If the files are rich-text or application-specific documents, use the document app’s own comparison or revision features where available; flattening or exporting them to plain text can omit formatting or structure.
Sources
DIFF(1) — Xcode’s man pages
Basic editing: Compare files — Visual Studio Code
BBEdit Comparison Chart — Bare Bones Software