[Techtalk] Listing differences between directory trees/contents

Little Girl littlergirl at gmail.com
Sat Apr 16 22:12:13 UTC 2022


Hey there,

David Sumbler wrote:

>I want to have a listing of the 2 directory trees, including file
>sizes, so that I can find the differences and correct things.  (A
>full 'ls -R' listing is over 3000 lines - there are a lot of
>files!).  With suitable listings I could perhaps use 'diff' to find
>the errors on the SD card, or import both listings to a spreadsheet
>which might be more flexible.
>
>For each file and directory I only need the relative path, the name
>and, in the case of a file, the size.  Despite a lot of internet
>searching I haven't found a practical way of achieving what I want,
>although it seems a pretty basic thing to want to do!
>
>Does anyone have a script that would do it, or suggestions about how
>I can get the result I want?

This isn't quite what you're after since it won't give you directory
listings or file sizes, but diff is perfect for the job and will let
you know exactly what's going on and where it's happening.

Example command:

diff -r --brief /path/to/folder1 /path/to/folder2

Example output:

Only in /path/to/folder1: foo.txt
Only in /path/to/folder2: bar.txt
Files /path/to/folder1/baz.txt and /path/to/folder2/baz.txt differ

My preference would be to use Meld, but that's a GUI. If you're open
to using a GUI and have never tried it, you're in for a treat.

-- 
Little Girl

There is no spoon.



More information about the Techtalk mailing list