FG
💻 Software

Linux: Compare Directory Structure Without Comparing Files

Fresh7 days ago
Mar 15, 202662900 views
Confidence Score1%
1%

Problem

What is the best and simplest way to compare two directory structures without actually comparing the data in files? This works fine: But it's really slow because it's comparing files too. Is there a switch for diff or another simple cli tool to do this?

Error Output

diff -qr dir1 dir2_

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Linux: Compare Directory Structure Without Comparing Files

Low Risk

The following (if you substitute the first directory for directory1 and the second for directory2) should do what you're looking for and swiftly: The fundamental principle is that it prints out all of the directories including subdirectory paths relative to the base directoryN directories. This could fall down (produce wierd output) if you have carriage returns in some of the directory names but not others.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment