LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Handling filename beginning with '--' in bash (https://www.linuxquestions.org/questions/linux-newbie-8/handling-filename-beginning-with-in-bash-412514/)

vjimin 02-07-2006 04:02 AM

Handling filename beginning with '--' in bash
 
Hello,

I accidentally created a filename that begins with `--exclude` (while running a careless tar command).

Now, everytime I try to rename or delete this file, I get an error:

Code:

unrecognized option `--exclude=`
I believe the mv and rm commands treat this as an option, regardless of whether I put it inside quotes or escape it with backslashes.

Can anyone please tell me how to get rid of this odd file? FYI, I'm on bash.

Thanks in advance,
VJ

vjimin 02-07-2006 04:18 AM

Sorry, found a solution myself. I'm blind... it was right there in the rm man page. Had to use either:

Code:

rm -- -foo

rm ./-foo


VJ

bathory 02-07-2006 04:18 AM

Use the "--" before the filename to terminate the list of options:
Code:

mv -- --exclude
or
rm -- --exclude



All times are GMT -5. The time now is 04:33 AM.