Deleting a file name beginning with a hyphen

jamesm@jamesmcdonald.id.au jamesm
Thu Oct 20 04:46:50 PDT 2005


As you can see from the following I have finally deleted this annoying
file with the name `-C' I was trying to delete it using \ to escape the -
characters. I was just on the verge of emailing Y'ALL when I had a final
go and
found that you have to specify the full path.... sigh live and learn


[root at apf-ma-qad01 root]# ls
anaconda-ks.cfg  -C                evolution    install.log.syslog
subversion
bin              desktop28install  install.log  mbox
[root at apf-ma-qad01 root]# rm '-C'
rm: invalid option -- C
Try `rm --help' for more information.
[root at apf-ma-qad01 root]# rm '\-C'
rm: cannot lstat `\\-C': No such file or directory
[root at apf-ma-qad01 root]# rm "\-C"
rm: cannot lstat `\\-C': No such file or directory
[root at apf-ma-qad01 root]# rm -C
rm: invalid option -- C
Try `rm --help' for more information.
[root at apf-ma-qad01 root]# rm \\-C
rm: cannot lstat `\\-C': No such file or directory
[root at apf-ma-qad01 root]# rm /root/-C
rm: remove regular file `/root/-C'? y
[root at apf-ma-qad01 root]#




More information about the Linux-users mailing list