Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

filename with '-'

0 views
Skip to first unread message

JD

unread,
Jan 2, 2007, 3:45:34 AM1/2/07
to
Hello,

I have a filename starting with '-' on my system (saved webpage).
How do I remove such a file? All commands I know interpret the '-' as a
command-line option.

Thanks

Felix M. Palmen

unread,
Jan 2, 2007, 3:54:09 AM1/2/07
to
* JD <j...@something.com>:

> I have a filename starting with '-' on my system (saved webpage).
> How do I remove such a file? All commands I know interpret the '-' as a
> command-line option.

This is kind of a unix shell faq ;)

Include two dashes (--) in your command line. after Them, nothing is
interpreted as an option.

Greetings, Felix

--
Felix M. Palmen (Zirias) \ -PGP- <f...@palmen.homeip.net> /"\ ASCII Ribbon
web: http://zirias.ath.cx/ \ http://zirias.ath.cx/pub.txt \ / Campaign
my open source projects: \ FP ED9B 62D0 BE39 32F9 2488 X Against HTML In
http://zirias.ath.cx/?pg=pro \ 5D0C 8177 9D80 5ECF F683 / \ Mail And News

CodeWright

unread,
Jan 2, 2007, 9:26:10 AM1/2/07
to

Felix M. Palmen wrote:
> * JD <j...@something.com>:
> > I have a filename starting with '-' on my system (saved webpage).
> > How do I remove such a file? All commands I know interpret the '-' as a
> > command-line option.
>
> This is kind of a unix shell faq ;)
>
> Include two dashes (--) in your command line. after Them, nothing is
> interpreted as an option.

That's not entirely true.

/Some/ utilities recognize the double dash option (--) as an "end of
options" marker, but some do not.

In any case, it is always safe to use a qualified path that /does not/
start with a dash to access (i.e. delete, copy, etc) files who's names
start with a dash

Thus, instead of
rm -.txt
use
rm ./-.txt
or
rm /full/path/to/-.txt

This works in /all/ shell environments, with /all/ utilities, whether
they recognize the double dash option or not.

HTH
--
Lew

0 new messages