Easy way to compare two iMac files to see if they are identical or where they differ?
I have two files with identical names I would like to compare them and see if I can send one to the trash.
[Re-Titled by Moderator]
iMac 21.5″
I have two files with identical names I would like to compare them and see if I can send one to the trash.
[Re-Titled by Moderator]
iMac 21.5″
You can compare two files entirely in Terminal—e.g. cmp file1 file2 returns nothing if they’re identical (exit code 0) and nonzero if not, while diff -u file1 file2 shows unified-diff-style line-by-line differences . For a graphical view, use Xcode’s FileMerge (invoked via opendiff file1 file2), which opens a dual-pane diff window with colored bands highlighting insertions, deletions, and changes . If you need folder-level comparisons or more polished UIs, third-party tools like DiffMerge, Meld, Beyond Compare, or Kaleidoscope offer side-by-side file and directory diffs with intra-line highlighting and merge capability . Finally, for a quick binary or integrity check, run md5 file1; md5 file2 (or shasum) to compare checksums—identical hashes mean identical files .
You can compare two files entirely in Terminal—e.g. cmp file1 file2 returns nothing if they’re identical (exit code 0) and nonzero if not, while diff -u file1 file2 shows unified-diff-style line-by-line differences . For a graphical view, use Xcode’s FileMerge (invoked via opendiff file1 file2), which opens a dual-pane diff window with colored bands highlighting insertions, deletions, and changes . If you need folder-level comparisons or more polished UIs, third-party tools like DiffMerge, Meld, Beyond Compare, or Kaleidoscope offer side-by-side file and directory diffs with intra-line highlighting and merge capability . Finally, for a quick binary or integrity check, run md5 file1; md5 file2 (or shasum) to compare checksums—identical hashes mean identical files .
In Terminal app…
To compare file1.txt and file2.txt using diff in Terminal:
diff -s /Users/yourusername/documents/file1.txt /Users/yourusername/documents/file2.txt
If the output is:
Files /Users/yourusername/documents/file1.txt and /Users/yourusername/documents/file2.txt are identical
Then the files are identical.
open Terminal, type…
diff -s
then a space, then drag 1st file to Terminal then drag 2nd file to terminal press enter.
Sure, Philippe! Here’s your answer in English, fully adapted for macOS users who want to compare two Mac computers—specifically, directory structures and file contents—and identify differences between them.
Accessing Both Systems
To compare directories between two Macs, ensure both are accessible:
Basic Comparison with diff
If you can access both directories locally (or one is mounted), this is the quickest command:
diff -qr /path/to/folder1 /path/to/folder2
🔍 This shows:
Advanced Comparison with rsync (no copy)
To check for differences without copying anything:
rsync -avun /path/folder1/ /path/folder2/
Graphical Comparison with Meld (recommended)
Install via Homebrew:
brew install --cask meld
Then run:
meld /path/to/folder1 /path/to/folder2
🧩 This gives you a visual diff of:
Deep File-Level Comparison with Hash Checks
For full integrity checks (e.g., duplicates or corrupt files), generate file hashes:
find /path/folder1 -type f -exec shasum {} \; > hash1.txt
find /path/folder2 -type f -exec shasum {} \; > hash2.txt
diff hash1.txt hash2.txt
This detects even subtle differences in binary or text content.
Easy way to compare two iMac files to see if they are identical or where they differ?