1

I've encountered a really weird problem on a NAS volume I'm accessing on OS X. I have a PNG file that I tried to delete, but something went wrong and it still appears when I run ls or view the directory in Finder (icon is blank, though). Here's where it gets freaky:

  • Running plain ls lists the file along with everything that does exist, no problem. Same thing with ls -a, -h, or -w.

  • If I run ls with -l or -i, or try to rm or mv the file, I get the error "No such file or directory" instead of output. Everything else that should show up does.

  • Running ls -s prints

    0 3-keys-to-manifestation-og.png
    

So I've got a file with zero size, that I cannot delete or rename. There is no issue with special characters in the filename, as was suggested with similar problems.

Any ideas about what happened, and how I can get rid of this thing?

6
  • 4
    So what is the output of ls | hexdump -C? Commented Mar 14, 2017 at 6:16
  • What's your rm command? Are you using wrong path?
    – FrontENG
    Commented Mar 14, 2017 at 6:33
  • What happens if you stat the file?
    – Wildcard
    Commented Mar 14, 2017 at 7:09
  • See whether find . -maxdepth 1 -name '*3-keys-to-manifestation-og.png*' -delete helps.
    – phk
    Commented Mar 14, 2017 at 15:37
  • What are directory permissions ? If you don't have write permissions on directory, you cannot add or remove files, because creating or removing files modifies directory listing. Commented Oct 11, 2019 at 7:29

2 Answers 2

1

Try to echo some content into the file and delete it then.

echo "Some Text" > 3-keys-to-manifestation-og.png && rm 3-keys-to-manifestation-og.png

I cannot say why this file is still shown in ls, but maybe you can delete it after it was "created" with the echo command.

If the file still exist, echo will overwrite its content with "Some Text". If it is not there anymore, it will be created and filled with "Some Text". Afterwards it should be possible to delete it.

0
0

I had a file which showed up via ls, but I couldn't rm it.

I was able to mv the file to a new directory.

In my specific case to get the file to show up in ls I had to use a wildcard (e.g. ls ./some*.jpeg) and I had to use the same wild card in mv (e.g. mv ./some*.jpeg ./newdir). Also, in my case I wanted to actually keep the file (but it was corrupted). However, once I moved the file to a new directory, I was able to move it back to the original directory and the file was no longer corrupted.

Not the answer you're looking for? Browse other questions tagged .