How can I delete a file which filename has non-printing characters

The file has a name, but it's made of non-printable characters. If you use ksh93, bash, zsh, mksh or FreeBSD sh, you can try to remove it by specifying its non-printable name. First ensure that the name is right with: ls -ld $'\177' If it shows the right file, then use rm: rm $'\177'

Another (a bit more risky) approach is to use rm -i -- * . With the -i option rm requires confirmation before removing a file, so you can skip all files you want to keep but the one.

Good luck!


For those who use vim run it in the current working directory:

$ vim ./ 

and navigate to the file with the arrow keys or j/k. Then hit Shift+D and confirm deletion with y.


There's probably a way to pass the filename to rm, but if you're worried about messing anything up you can use a GUI file manager. Emacs comes with a directory editing mode you can use if you have it installed:

  1. Open the folder in emacs. You can run emacs /path/to/folder, or open emacs, hit Esc+x, and run dired, which will prompt for the path

    http://so.mrozekma.com/unix-dired-delete1.png

  2. Move to the row with the file you want to delete and press d. You should see a D in the left margin next to the file:

    http://so.mrozekma.com/unix-dired-delete2.png

  3. Press x to save your changes. It'll prompt to make sure you want to delete the file; press y:

    http://so.mrozekma.com/unix-dired-delete3.png