September 7, 2010 · General · Email This Post

Solution 1

To remove a file with dashes, slashes or other special characters, the easiest way is to access the file using its inode. To get the inode of a file, just do a ls -li. When you have that number, use find to delete the file using the following command:

find . -inum [inode] -exec rm -i {} \;

Solution 2

To remove a file whose name starts with a `-‘, for example `-foo', use one of these commands:

rm --- -foo
rm ./-foo


$ rm --- -\,my\?\ funky.file\$name

Via Johnny chadda

Sponsored Link

Incoming search terms:

Related posts

2 Comments to “How to remove files with special characters in Linux”

  1. nutznboltz says:

    I use emacs dired to work files that have unprintable characters in their names.


  2. del says:

    I was always wondering how to do it from the command prompt… The “easy” way was to use mc (midnight commander) to do it. Thank for the nice trick. :)


Leave a Reply