Answer the question
In order to leave comments, you need to log in
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/>
/home/user/test/<b>F</b>irst/test<br/>
/home/user/test/first/test<br/>
Answer the question
In order to leave comments, you need to log in
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
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
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
=) 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 questionAsk a Question
731 491 924 answers to any question