Search code examples
linuxrm

Delete a file in linux that contains double dash


Possible Duplicate:
Unable to remove a special named files in terminal

I feel silly asking, but how can I delete a file in linux named --preserve-permissions?

I tried:

rm "--preserve-permissions"

and

rm "\-\-preserve-permissions"

Neither works. Thanks.


Solution

  • There are several techniques, but the most straightforward for this kind of filename is:

    rm ./--preserve-permissions
    

    For filenames with unprintable or hard-to-decipher characters, use

    rm -i *
    

    This prompts with each filename and waits for a y or n whether to delete the file (interactive).