Compare the contents of two directories
Read-only
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Shows which files differ, and which exist only on one side, between two directory trees — for checking a backup, a deploy, or a copy operation.
filesdiffcomparebackup
Parameters
First directory to compare.
Second directory to compare.
Commands
List files that differ or exist only in one directory
diff -rq "<left>" "<right>"Verification
diff -rq "<left>" "<right>" | wc -lZero lines means the trees are identical; each line is one difference.
Undo
Not undoable
This recipe only compares files and changes nothing.
Pitfalls
- diff -rq compares contents; the PowerShell variant compares file lists only — pair it with Get-FileHash to compare contents.
- Symlinks are followed by default, which can make identical trees look different or recurse unexpectedly.