I made a file by accident with a filename of (NUL).xml, except instead of (NUL), it's literally '\0'. None of the methods I've tried have worked to actually delete it. Is there a way I can delete the file by an alternative reference?

  • I created it with an old version of Java that let me create files with a null byte in the file name by accident. Unfortunately, I've long since updated and clri isn't available on El Capitan, so I can't even clear the inode. – CassOnMars Mar 3 '16 at 1:02
  • I've tried that and many more. It doesn't work. – CassOnMars Mar 3 '16 at 1:08
  • I'm more or less hoping someone has a method for clearing inodes on El Capitan. – CassOnMars Mar 3 '16 at 1:09
  • The problem with that is that it attempts to delete the file using the file's name, which is exactly the problem. The null byte is tripping up rm. – CassOnMars Mar 3 '16 at 1:10
  • Yeah. That runs into the same problem as its invoking the unlink() call against the file name. – CassOnMars Mar 3 '16 at 1:21

Ok, so I cannot test this (for hopefully obvious reasons), but when filenames are your issue... use inodes!

First, in a directory, run ls -il (-i is show node numbers and -l is to make it a list):

2480878 -rw-r--r--  1 christopher  family  0 Mar  2 19:40 *a
2480889 -rw-r--r--  1 christopher  family  0 Mar  2 19:40 \\a
2480873 -rw-r--r--  1 christopher  family  0 Mar  2 19:39 a

In this example, I'm going to erase the file \\a, which is inode 2480889.

So I run find . -inum 2480889 -delete.

Hopefully this will work.

  • find . -inum 43396691 -delete produces find: -delete: unlink(./␀.xml): Invalid argument – CassOnMars Mar 3 '16 at 17:58
  • :( darn! That sucks! – iAdjunct Mar 3 '16 at 18:42

You must log in to answer this question.

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