Duplicated filenames in the same directory
The (WD 320GB) drive has a single ext3 FS on it. It has had some problems in the past, but all were fixed with fsck -y. Now there are several directories with duplicate filenames. The files with duplicated names are hard links of each other, but the names are identical. I've run several diagnostics over them, looking for, eg, non-printing characters in the name, but they are completely identical. Here are some examples:
Code:
$ ls -l | awk '$2 == 2{print}' I always thought duplicate filenames in the same directory were impossible in unix/linux; this appears to prove me wrong. Am I missing something? (Kernel version 2.4.20 with xfs extensions. The installation was originally Red Hat 7, but I've changed almost everything, so it's probably more accurate to call it a custom distro.) |
I know you said that you've checked but could you please post the output of 'ls -liq <dir>' where <dir> contains one of these duplicates ? .. your output doesn't show the full paths, can you confirm the paths are identical as well ?
|
It's possible for a filename to have a non-printing character,
such as ^H. If you had files named "file1.txt" and "file12^H.txt" and typed "ls" it would appear that you have duplicates. Use "ls | cat -vt" to see any non-printing characters. |
Quote:
Code:
$ ls -liq . | awk '$3 == 2{print}' Thanks Wocky |
Quote:
Wocky |
Quote:
Sorry, kbp, I've just re-read that. Here it is again: Code:
$ ls -liq /home/Wocky/temp_audio/mp3 | awk '$3 == 2{print}' |
This is odd. I would umount the filesystem and run fsck -y again.
|
The 2 is the link count to the same file.
If the inode numbers were different, they would be different files with identical names and you could use "find -inum <#> -exec mv '{}' dir/ \;" to process them. If fsck won't correct the directory (they are files to the kernel). One thing you might try is something like: makedir dupes find ./ -maxdepth 1 -links 2 -type f -exec '{}' dupes/ \; mv dupes/* . rmdir dupes This will copy files with a link count of 2 in the current directory to the dupes/ subdirectory. Since they have the same name, you should end up with one file name in the subdirectory. Maybe backup a couple of these to another directory for testing. To make sure it works. I can't test it since I can't create 2 links to the same file with the same name. |
All times are GMT -5. The time now is 02:58 PM. |