Removing a filename containing a null byte or binary character on Linux
Somehow, I got a file in my tree that started with a null byte. I only discovered it because git status was noting it wasn't added to my branch, and wanted to know if I wanted to add it.
No, no, I did not. I wanted to delete it.
But, of course, you cannot reference such a file by name, so I had to learn a few tricks.
First off, you can list names with binary bytes using:
/bin/ls -lb
But even better, you can get the inode if you use:
/bin/ls -li
When you do, the inode is in the first column of the list for each file.
Once you know that, you can delete the file, using find:
find . -maxdepth 1 -inum <inode_id> -exec rm -i -- {} +