[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Files starting with a dash



On Tue, Jan 21, 2003 at 10:24:32AM -0600, Erich Schroeder wrote:
> A long time ago some one built a portion of a web site and used file names 
> that start with a dash "-". I can't get them renamed now. I've tried 
> 
> mv \-name.htm name.htm
> mv "-name.htm" name.htm
> mv '-name.htm" name.htm
> mv `-name.htm` name.htm
> 
> and the same thing in cp. Each command thinks that the -n is an option. 
> This must be a FAQ, but I can't find it.

Most of the GNU tools will accept -- as an option terminator.  In
other words, "rm -- -rf" would remove a file named "-rf".  That's not
really necessary though, since you could also do "rm ./-rf".  There's
always perl too...

So for your example, the following would work:

    mv ./-name.htm name.htm
    mv -- -name.htm name.htm
    perl -e 'rename "-name.htm", "name.htm" or die $!'

Steve
-- 
steve@silug.org           | Southern Illinois Linux Users Group
(618)398-7360             | See web site for meeting details.
Steven Pritchard          | http://www.silug.org/

-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.