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.
You can use standard UNIX or Linux rm command to delete a file name starting with - or -- . All you have to do is instruct the rm command not to follow end of command line flags by passing double dash -- option before -foo file name.
Last Updated: November 10th, 2020 by Hitesh J in Linux. In Unix or Linux operating systems, working with dashed filename requires some attention. In some cases, you may need to handle files with a dash (-) as the first character. Because dash (-) is generally used by commands to specify options and arguments.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With