Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need to get a list of all the files that only differ in case.

I.e., if I have a folder (with sub-folders) with the files:

one.txt
ONE.txt
two.txt
three.txt
three.TXT
four.txt
five/5.txt
five/6.txt
five/6.Txt

I want some bash magic that will spit out:

one.txt
ONE.txt
three.txt
three.TXT
five/6.txt
five/6.Txt
share|improve this question
    
Why the downvote? I know this isn't a very deep question, but it was something I needed to know and something I knew would be answered by someone here. –  David Oneill Oct 2 '13 at 20:59

2 Answers 2

up vote 4 down vote accepted
ls -R | uniq -Di

should do it for you, supposing your locale sorts upper and lower case letters together. If your local is C, all bets are off.

export LC_ALL=C
share|improve this answer
2  
Wow! Simple and great..:) I suggest to use find . instead of ls if he wants to find in subdirectory also. For example: find . | uniq -Di or find . | sort | uniq -Di –  Saurav Kumar Oct 2 '13 at 20:35
    
Thanks - I knew there had to be a simple way of doing that! (For posterity, use find . instead of ls. See @RaduRădeanu's link if you care) –  David Oneill Oct 2 '13 at 20:57
    
You shouldn't parse the output of ls. See mywiki.wooledge.org/ParsingLs. Anyways, you should use ls -R | uniq -Di to answer the question... (with sub-folders) –  Radu Rădeanu Oct 2 '13 at 21:02

This is closest to what you want:

find . -type f | sort | uniq -iD | awk -F"\.\/" '{print $2}'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.