Mozilla Skin

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:

  1. unlink '--option=backup'. The program unlink directly uses the Linux unlink system call to delete files, so does not encounter the same problem as rm
  2. In general, GNU programs allows you to indicate there will be no more option switches with --. Hence rm -- '--option=backup' will work nicely.
  3. Or you can do rm ./--option=backup.
  4. Another way of deleting files is to delete the inode of the file.
  5. And yes, Konqueror can delete that file too.

Source: LUGS Mailing List