Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a folder with so many files whose name has multiple colon signs. For example: Mail::Message::Field::Full.3pm.gz.

I wonder how to delete them.

I have tried

rm Mail::Message::Field::Full.3pm.gz
rm Mail\:\:Message\:\:Field\:\:Full.3pm.gz
rm "Mail::Message::Field::Full.3pm.gz"

All with the same result: rm: cannot remove 'Mail::Message::Field::Full.3pm.gz': Input/output error.

Also, I have tried with my normal user account and with root user. In both cases with the same result as above.

rm with -f option has the same result.

The same problem applies when renaming the files.

And of course, I have writting permissions on that folder.

The output of ls -l is

ls: cannot access Mail::Message::Field::Full.3pm.gz: Input/output error
-????????? ? ? ? ?            ? Mail::Message::Field::Full.3pm.gz

I do not know if this matter but the files are on a NTFS partition.


Update

I do not think is a hardware issue. I am able to access (write, delete, create, decompress, etc) all other files. Although, I cannot access the problematic files.

share|improve this question
2  
I don't think the colons have anything to do with it; it seems like there's something wrong with the partition the file is stored on. Is it a network mount? –  Michael Mrozek Jul 7 '12 at 22:49
    
@MichaelMrozek It is a external hard drive. I am able to delete "normal" files. For example, touch test, rm test works as expected. –  ceochronos Jul 7 '12 at 22:55
    
Can you access/read the specific files that are giving you trouble? Another thing to try would be to mount this drive on a different system if you can for troubleshooting purposes. –  Levon Jul 7 '12 at 22:56
1  
How were the files created? The same driver that allowed them in is more likely to understand them now. –  Gilles Jul 7 '12 at 23:22
1  
@ceochronos Then maybe it's worth trying an older version of the ntfs-3g driver, in case this is a bug in the current version. Note that this driver is a userland driver using FUSE, so you don't need to do anything kernel-related or even to be root to use a different driver, it's just a program that you run. –  Gilles Jul 7 '12 at 23:40
show 5 more comments

3 Answers

up vote 4 down vote accepted

It matters very much that the file is on an NTFS partition.

The : sign is not a special character on most unix systems, and in particular not on Linux (only / is special). It does not have any significance to the kernel (some applications do give it special significance though, so it is best not to use it). On most unix filesystems, including Linux's habitual ext2/ext3/ext4, you can use : in a file name just like any other character.

NTFS has more stringent (but optional) rules, because it comes from the Windows world. In Windows, : is not allowed in file names (or rather, it is allowed at the kernel level but not supported by most applications, including the default shells). The open source NTFS driver NTFS-3G tries to prevent you from creating file names with : in it, and may be confused if it finds an existing invalid file name.

The NTFS-3g manual states that

it always creates new files in the POSIX namespace for maximum portability and interoperability reasons. This means that filenames are case sensitive and all characters are allowed except '/' and '\0'. This is perfectly legal on Windows, though some application may get confused.

Make sure that you're using the latest version of the ntfs-3g driver, and that the filesystem is not mounted with the windows_names option.

share|improve this answer
    
At this moment I am doing a backup from the server, laptop and desktop to the external hard drive. When it finish I will mount it in another machine or using a live CD of Ubuntu 10.04 or mounting manually and changing the mount parameters. –  ceochronos Jul 7 '12 at 23:50
add comment

When you say the same applies when renaming, do you mean you can't rename them, or you manage to rename them, but then you have the same problem when deleting (probably not I'm guessing).

Just checking, did you try using wildcards, if you don't have too many files you could try something like

 rm -i Mail*essag**.gz

The -i will result in you getting prompted before the delete, so you can check to make sure you are only deleting the files(s) you want.

Though I suspect this is an issue with permissions, or file system, rather than the filename characteristics. Or possibly an indication of some hardware failure.

share|improve this answer
    
I cannot rename the files. I get the same error. mv: cannot stat Mail::Message::Field::Full.3pm.gz': Input/output error –  ceochronos Jul 7 '12 at 22:51
    
@ceochronos Can you try the wildcard with the -i? Though I suspect it's a problem with permissions/mounted file system. –  Levon Jul 7 '12 at 22:52
    
rm -i Mail*essag**.gz outputs a line per file that matches ... rm: cannot remove Mail::Message::Field::Full.3pm.gz': Input/output error ...` –  ceochronos Jul 7 '12 at 23:08
    
@ceochronos .. ok, well, the fact that you have no problems with other files makes me think that hardware is not an issue, so perhaps permissions with these particular files in regard to the other filesystem. Out of ideas at this point .. but I will follow the thread for solutions. –  Levon Jul 7 '12 at 23:12
add comment

After reading through all the back and forth on this, I suspect that the NTFS filesystem has been damaged.

I recommend:

  1. Booting into Windows
  2. Performing a full filesystem check (Linux tools are not, yet, really sufficient to this task)
  3. Booting back into Linux, and trying again.
share|improve this answer
add comment

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.