LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   duplicate files (https://www.linuxquestions.org/questions/linux-newbie-8/duplicate-files-817577/)

sarew 07-02-2010 02:56 AM

duplicate files
 
How can I find a list of files that are named duplicates i.e. have same name but in different case that exist in the same directory?

colucix 07-02-2010 03:18 AM

Hi and welcome to LinuxQuestions!

From the top-level directory (if you need to descend recursively into a directory tree) you might try:
Code:

find | uniq -id

arizonagroovejet 07-02-2010 03:00 PM

Quote:

Originally Posted by colucix (Post 4021446)
Code:

find | uniq -id

That doesn't produce anything useful when I try it.

I think the first thing to note is that "same name but in different case" is actually something of an oxymoron. If the case is different, they do not have the same name. E.g. hello and HeLLO are two different names.

The closest I've been able to get is this

Code:

mike@continuity:/tmp$ touch hello
mike@continuity:/tmp$ touch HEllO
mike@continuity:/tmp$ touch Hello
mike@continuity:/tmp$ find . -iname \* 2>/dev/null | sort | uniq -id
./hello
mike@continuity:/tmp$

The output of the find command tells me that there is more than one file with a name that is a variant of hello. But it doesn't tell me that the other files are call. I can find them with another find command though

Code:

mike@continuity:/tmp$ find . -iname hello 2>/dev/null
./HEllO
./Hello
./hello


fruttenboel 07-02-2010 03:10 PM

Quote:

Originally Posted by sarew (Post 4021424)
How can I find a list of files that are named duplicates i.e. have same name but in different case that exist in the same directory?

as root run 'updatedb'

when the process is finished, and you are looking for file 'gobbledigook' run

Code:

locate gobbledigook
Done.

updatedb runs as a cron job and executes every day at 10 PM.

arizonagroovejet 07-02-2010 03:40 PM

Quote:

Originally Posted by fruttenboel (Post 4022087)
as root run 'updatedb'

locate, of course! I should have thought of that. It's not installed by default by all distributions. On SUSE distros it's in the package findutils-locate.

Quote:

Originally Posted by fruttenboel (Post 4022087)
Code:

locate gobbledigook

You need to use the -i option to get a case insensitive search.

Code:

locate -i gobbledigook


Quote:

Originally Posted by fruttenboel (Post 4022087)
updatedb runs as a cron job and executes every day at 10 PM.

It might run at 10PM on your machine, that doesn't mean it runs at 10PM on all Linux machines. It probably will be run at least once a day, but when it runs will vary depending on the Linux distribution being used.

fruttenboel 07-03-2010 04:21 AM

Quote:

Originally Posted by arizonagroovejet (Post 4022116)
You need to use the -i option to get a case insensitive search.

Code:

locate -i gobbledigook

Hey thanks for that. I'm using locate so long now that I never came to reading the man pages...

Quote:

It might run at 10PM on your machine, that doesn't mean it runs at 10PM on all Linux machines. It probably will be run at least once a day, but when it runs will vary depending on the Linux distribution being used.
True. I was not completely clear there. On my slackware systems it is installed by default. I put it in crontab to run at 10 PM, that being a time the machine will be running in the majority of times.

Baresi 07-06-2010 07:40 AM

<<mod edit: Advertising deleted>>

pixellany 07-06-2010 09:30 AM

Baresi;

Do not post advertising links---especially ones advertsing Windows SW!!


All times are GMT -5. The time now is 08:23 AM.