How to find duplicate files with same name but in different case that exist in same directory in Linux?

The other answer is great, but instead of the “rather monstrous” perl script i suggest perl -pe ‘s!([^/]+)$!lc $1!e’ Which will lowercase just the filename part of the path. Edit 1: In fact the entire problem can be solved with: find . | perl -ne ‘s!([^/]+)$!lc $1!e; print if 1 == $seen{$_}++’ Edit 3: I … Read more

How do I capture the output from the ls or find command to store all file names in an array?

To answer your exact question, use the following: arr=( $(find /path/to/toplevel/dir -type f) ) Example $ find . -type f ./test1.txt ./test2.txt ./test3.txt $ arr=( $(find . -type f) ) $ echo ${#arr[@]} 3 $ echo ${arr[@]} ./test1.txt ./test2.txt ./test3.txt $ echo ${arr[0]} ./test1.txt However, if you just want to process files one at a … Read more

Which is the fastest STL container for find?

For searching a particular value, with std::set and std::map it takes O(log N) time, while with the other two it takes O(N) time; So, std::set or std::map are probably better. Since you have access to C++0x, you could also use std::unordered_set or std::unordered_map which take constant time on average. For find_if, there’s little difference between … Read more