command/script for finding *non*duplicate files?

Adam Funk a24061 at ducksburg.com
Mon Feb 8 15:29:35 UTC 2016


On 2016-02-08, Karl Auer wrote:

> On Mon, 2016-02-08 at 10:14 +0000, Adam Funk wrote:
>> I'm looking for a
>> way to find files in one directory (& its subdirectories) that are
>> *not* duplicated in another one.
>> [...]
>> Any ideas?  (I tried googling 'find non-duplicate files' & things like
>> that, but it just keeps telling me how to find duplicate ones.)
>
> Think about it this way: The non-duplicate ones are the ones that are
> left when you've removed the duplicate ones.

True...

> So 1) make a list of all the files in both directories
>    2) remove all the duplicates
>    3) the remainder are the non-duplicates
>
> ls -c 1 /that/directory/path > t1.txt
> ls -c 2 /this/directory/path > t2.txt
> cat t1.txt t2.txt | sort | uniq -u
>
> sort puts identical lines together, uniq -u throws away all non-unique
> lines leaving only the unique ones.
>
> To make the comparison case-insensitive use -i option to uniq as well.
> In fact, read "man uniq" and "man sort" :-)

...but that won't work because the files may have been renamed.





More information about the ubuntu-users mailing list