Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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

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

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

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

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

I'm not sure if any of the answers here have actually had the issue Stig reported. I just ran into this problem myself on my ext4 filesystem:

# ls -l /tmp/dependencies/
ls: cannot access /tmp/dependencies/easy-rsa-master: No such file or directory
total 0
?????????? ? ? ? ?            ? easy-rsa-master

# ls -i /tmp/dependencies/
ls: cannot access /tmp/dependencies/easy-rsa-master: No such file or directory
? easy-rsa-master

# rm -r /tmp/dependencies
rm: descend into directory ‘dependencies’? y
rm: cannot remove ‘/tmp/dependencies/easy-rsa-master’: No such file or directory
rm: remove directory ‘dependencies’? y
rm: cannot remove ‘dependencies’: Directory not empty

The file itself was corrupt along with its file attributes. ls -i clearly shows no inode ID. No usage of rm will do the trick. Even rm -rf traverses into the directory and tries to delete the file directly (and silently).

My solution was to recreate the directory without the offending file. Then you can move the directory to another location, like /tmp. It'll be gone after a reboot or whenever your distro cleans the /tmp directory (hopefully).

share|improve this answer

You must log in to answer this question.