Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How I can delete this file? I think it is a corrupt file in a VFAT file system.

?????????  ? ?       ?        ?            ? 100.jpg
share|improve this question

migrated from stackoverflow.com Oct 9 '10 at 6:50

This question came from our site for professional and enthusiast programmers.

    
What particular error(s) do you encounter when you try to delete it normally? –  Ruel Oct 9 '10 at 6:36
    
Could you add the output of ls -B ? –  Hennes Oct 1 '13 at 18:34

5 Answers 5

If you want to delete every corrupt files, you can do this:

ls -1 | grep -P "[\x80-\xFF]" | xargs rm

Above grep command grep files which has non ASCII characters.

share|improve this answer

One possibility is to find out the inode number of the file, which you can do by running ls -i. This will return two columns -- the first being the inode, and the second being the filename. You can then use the find command to select only the file with that specific inode, and delete it.

sh-4.1$ ls -i .
  17921 somefile.ods
    169 someotherfile.conf
    305 -????????? ? ? ? ? ? 100.jpg
  18048 yetanotherfile.jpg

sh-4.1$ find . -maxdepth 1 -inum 305 -ok rm '{}' \;
< rm ... -????????? ? ? ? ? ? 100.jpg > ? y

Since the inode is most likely unique to the file (assuming no hardlinks), this will allow you to delete without the risks inherent with wildcards. The maxdepth and the ok options of the find command just make it even less likely that you'll hit the wrong file by accident.

share|improve this answer

You can try this:

  1. Rename your directory.
  2. Recreate the original directory (empty).
  3. Copy other files back to it.
  4. Delete the directory containing that file.
share|improve this answer

I'd recommend a slightly more defensive version of cHao's suggestion:

rm -i ./*100.jpg*

The -i makes rm ask you whether or not to delete each file that matches the wildcard; this ensures that you won't accidentally delete other files as well. And the leading ./ ensures that all the filenames will be treated as filenames and not further options to rm (it looks like you might have a leading dash in there, is why this is important).

It's possible, by the way, that there are invisible characters inside the string "100.jpg". If the above gives you an error message like "rm: ./*100.jpg*: not found", that's why. ls -1fw | cat -v may be helpful.

share|improve this answer
    
Heh...i didn't even see the dash. Good catch. :) –  cHao Oct 9 '10 at 7:43

You might try

rm *100.jpg*

The ?'s are either literal question marks or characters that don't make sense. Either way, the OS itself (and the shell) can usually remove the file, if the filesystem isn't hosed.

If the filesystem is messed up, though, deleting stuff may make it worse. I'd recommend you boot into Windows to scan the drive, and delete the file there if you can.

share|improve this answer

Your Answer

 
discard

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