U
U
ursul2012-05-16 16:47:52
linux
ursul, 2012-05-16 16:47:52

How to get a list of duplicates by filename [Debian]?

Hello habrusers, the task is as follows:
It is necessary to recursively find files with different case in the names
Let's say:

/home/user/test/Te<b>S</b>T.xml<br/>
/home/user/test/TesT.xml<br/>
<br/>
/home/user/test/first/test<br/>
/home/user/test/first/<b>T</b>est<br/>

As well as directories with the same name, but different case
/home/user/test/<b>F</b>irst/test<br/>
/home/user/test/first/test<br/>

and just output them to the log file.
Dug in the direction of find , grep, fslint , fdupes unsuccessfully (didn't manage to implement what I wanted).
fdupes outputs a lot of duplicates (15k lines). As I understand it, it checks the file size and md5. I just need a name.
Who has any ideas? Examples.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
B
bagyr, 2012-05-16
@bagyr

find. | tr '[:upper:]' '[:lower:]' | uniq -d

@
@sledopit, 2012-05-16
_

sort is needed for sure. And on three files it worked, because I was lucky. If files with similar names were first and last, it wouldn't work.
PS compare for fun

echo -e "111\n222\n111\n333\n123" | uniq -d
echo -e "111\n222\n111\n333\n123" | sort | uniq -d

U
ursul, 2012-05-16
@ursul

There is a solution =) I'm quite happy with it.
You can, in principle, finish it, but the team worked for 150 thousand. files correctly.
If anyone is interested, here is an example Thanks bagyr for the tip.
for f in `find . | tr '[:upper:]' '[:lower:]' | sort | uniq -d`; do find . -iwholename $f; done

A
Alukardd, 2012-05-16
@Alukardd

In view of the above, I just rewrote your version.

IFS=$'\n'; for f in $(find /tmp/testdir | sort | uniq -di); do find /tmp/testdir -iwholename "$f"; done

U
ursul, 2012-05-16
@ursul

=) Thanks for the rewritten script. Everything has already worked without a cycle through the directories, so as not to load the machine.
About spaces in names. I did not pay attention to this, because. there was a 146% guarantee that the files were without spaces. But for those interested in my question, I think it will be useful.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question