[CentOS] Removing a file that starts with dashes

m.roth at 5-cent.us m.roth at 5-cent.us
Wed Apr 2 14:51:00 UTC 2014


Frank M. Ramaekers wrote:
> How can I remove this file?
>
> -rw-r--r-- 1 root    root       28707 Mar 31 12:31 --backup=numbered
>
> I've tried a few different methods, but most attempts interprets the
> file name as a switch (which it doesn't understand).

Method 1: try rm \-\-backup\=numbered
Method 2, that will *ALWAYS* work:
ls -i
then, using the inode number
find . -inum <inode> -exec rm {} \;

The latter method is the one guaranteed to take care of all kinds of
filenames with weird, or unprintable, stuff in the name.

       mark




More information about the CentOS mailing list