Deleting files with weird file names
From Linux & Open Source @ NUS
Say, you have a program that has a weird filename, such as "--option=backup" (without the quotes). It can't be deleted using rm or renamed using mv.
[user@system /]# rm '--owner=backup'
rm: unrecognized option `--owner=backup'
Try `rm --help' for more information.
[user@system /]# rm '*owner\=backup'
rm: unrecognized option `--owner=backup'
Try `rm --help' for more information.
[user@system /]# mv '--owner=backup' nothing
mv: unrecognized option `--owner=backup'
Try `mv --help' for more information.
Solution? There are several:
-
unlink '--option=backup'. The program unlink directly uses the Linux unlink system call to delete files, so does not encounter the same problem asrm - In general, GNU programs allows you to indicate there will be no more option switches with
--. Hencerm -- '--option=backup'will work nicely. - Or you can do
rm ./--option=backup. - Another way of deleting files is to delete the inode of the file.
- And yes, Konqueror can delete that file too.
Source: LUGS Mailing List
