Monday, April 29, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 739  / 2 Years ago, sat, july 2, 2022, 8:20:31

Scenario:



  • 2 main folders, that may have subfolders with the same names (I do not know what names might be duplicated, that's what I am trying to find)

  • the subfolders have MANY other files & subfolders so tools with automatic recursion are not really an option

  • I only care about duplicate subfolder names on the first level of the two main folders

  • contents of the subfolders don't matter

  • contents of the files don't matter


I tried using meld GUI but that just takes endless time to finish for these structures.


I tried using diff --brief --report-identical-files folder1 folder2 but that basically reports everything and it does not even include the folders so I can't even | grep identical.


Am I using wrong tools? Or is there some trick that I didn't get from diff --help ? Or am I doing something wrong?


Thanks


More From » command-line

 Answers
3

I'd use a simple find:


find "/path/to/main1" "/path/to/main2" -mindepth 1 -maxdepth 1 -type d -printf '%f
' | sort | uniq -d

Or to make it zero-terminated to prevent issues with newline characters:


find "/path/to/main1" "/path/to/main2" -mindepth 1 -maxdepth 1  -type d -printf '%f0' | sort -z | uniq -zd | xargs -0

[#949] Monday, July 4, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
huovie

Total Points: 234
Total Questions: 99
Total Answers: 105

Location: Central African Republic
Member since Sun, Feb 26, 2023
1 Year ago
huovie questions
Mon, Aug 2, 21, 01:46, 3 Years ago
Thu, Feb 2, 23, 10:58, 1 Year ago
Thu, Oct 21, 21, 08:55, 3 Years ago
Sun, Dec 5, 21, 23:57, 2 Years ago
;