Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a machine containing a large number of files that were originally created on a mac with some sort of special character in the name (not sure what). When I do an ls in a bash terminal, these files show up something like the following:

$ ls -al
ls: cannot access ._BLM?OAS: No such file or directory
ls: cannot access BLM?OAS: No such file or directory
total 20476
drwx------+ 43 Integr None       0 Sep  7 09:19 .
drwx------+ 16 Integr None       0 Sep  7 09:19 ..
-rwx------+  1 Integr None   24580 Jul  6 14:27 .DS_Store
???????????  ? ?      ?          ?            ? ._BLM?OAS
drwx------+  2 Integr None       0 Sep  7 09:19 66-North
.
.
.

Note particularly the errors after the ls and the file with all the ? in it's name. Now I know I can delete the ._ file safely, except that when I try to do that it doesn't work:

$ rm ._*        
rm: cannot remove `._BLM?OAS': No such file or directory

So how can I remove these files? There are literally several hundred of them, so one-by-one doesn't work. I know I can add the -delete flag to find to delete all found files, but doing a 'find . -name "._*" -delete' results in the same error (only repeated hundreds of times). Thanks.

share|improve this question
1  
Give the ???? in the permissions and owner/group fields I suspect you may have some file-system corruption going on there. –  Zoredache Sep 7 '10 at 18:08
    
That seems to be a common response, but from what I can tell (fsck and the like) the file system is fine- it's just these files. –  ibrewster Sep 8 '10 at 16:25
    
On further examination, it would appear that some of these question marks may be asian characters or the like. In some cases, the question mark shows up in the middle of a date, which would imply to me that it is a / - not allowed on a unix system, but just fine on the mac where these files were originally created. Don't know if that helps any. –  ibrewster Sep 8 '10 at 16:35
add comment

2 Answers

You can remove the file by encasing it in single quotes:

wmoore@bitbucket(/tmp)$ touch '._BLM?OAS'
wmoore@bitbucket(/tmp)$ ls -l ._BLM?OAS
-rw-r--r--  1 wmoore users 0 Sep  7 14:04 ._BLM?OAS
wmoore@bitbucket(/tmp)$ rm -f '._BLM?OAS'
wmoore@bitbucket(/tmp)$ ls -l ._BLM?OAS
/usr/bin/ls: ._BLM?OAS: No such file or directory

However, being as that the files status contains a bunch of question marks, this leads me to believe you have a corrupt filesystem. I recommend a fsck, which may correct the data.

share|improve this answer
    
That would work if the ? was a literal question mark, as in your example. However, in this case the question mark indicates that the shell does not recognize the character, not that it IS a question mark. If I look at the same file in windows 7, for example, it shows up with a • in the same position. Again, I don't believe this to be a literal •. Mac shows some weird symbol looking character. The file system appears fine, I think it's just these files that have issues. –  ibrewster Sep 8 '10 at 16:19
    
What happens with tab completion? –  Warner Sep 8 '10 at 17:49
    
Different files than the original, but same issue. First with tab completion, second with single quotes: control@fai-acc6 /tmp/the most relaxing feel $ rm 03\ \?\?.mp3 rm: cannot remove 03 ??.mp3': No such file or directory control@fai-acc6 /tmp/the most relaxing feel $ rm '03 ??.mp3' rm: cannot remove 03 ??.mp3': No such file or directory –  ibrewster Sep 8 '10 at 20:55
add comment

Are these files on an LVM volume? If so, it looks as though you may have lost one or more physical or logical volumes in the volume group. This will cause ls -l to show all those question marks, because ls thinks the file is there (as it is listed in the directory inode), but it will be unable to stat it to get permissions, size, ownership, etc. because the inode is not actually present.

I've had this happen to me before, but in my case LVM was being used by a commercial clustered filesystem (IBRIX), so the solution I used was somewhat specific to that product. Novell has a page describing how you might recover from LVM problems here that might be helpful. CentOS has another one here.

However, if this is just a regular old partition with a non-clustered filesystem sitting on it (e.g. ext3 on /dev/sda5, or whatever), then a simple fsck may be all you need to do.

Definitely check your logs and the output from dmesg. If you really did lose a physical or logical volume, you should see errors from LVM or the underlying hardware devices. That will give you some indication of what really happened, which you'll need to know in order to fix it.

share|improve this answer
    
No LVM or the like- just a normal single partition on a local drive. fsck shows clean, and I get the same behavior when moving these files to other drives. FWIW, if I mount the drive on a windows or mac machine and rename the file using windows explorer or the mac finder, then everything works. It's just that there are too many of these files to do that with- I need a scriptable solution. –  ibrewster Sep 8 '10 at 16:23
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.