On Sun, 4 Mar 2007 15:43:54 ido wrote:
>
> How can I rename and/or delete a file that starts with minus ?
> For example:
>
> mv --test test
>
> will end up with the error:
> mv: unrecognized option `--test'
> Try `mv --help' for more information.
>
> The same error will exists if I'll use the asterisk wildcard instead.
> Please note that I'm looking for a "mv" and "rm" based solutions and
> not the use (for example) midnight commander.

The problem is that the name is interpreted as an option because it
begins with - . You must cause `mv'/`rm' to know that -test is not an
option. You can do it in some ways:

1. You can add -- before the file name, this signals mv/cp/ln/rm that
   all the options has been processed, and file name(s) follow.  This
   is the prefered way - that's why it was built into the file commands.
   e.g. mv -- --test test
        to delete a file named "--" do: rm -- --

2. You can add directory specification to the file name and so it
   won't start with -, any file can be written as ./file .
   e.g.  mv ./--test test

Any way that will make the 1st file name NOT to start with - will work.
e.g. rm -f dummy-name -file-1 --file-2

Ehud.


--
 @@@@@@ @@@ @@@@@@ @    @   Ehud Karni                       אהוד קרני
     @    @      @  @@  @   Senior System Support   תמיכה במערכות מחשב
     @    @ @    @ @  @@    Mivtach - Simon               מבטח - סימון
     @    @ @    @ @    @   Insurance agencies          סוכנויות לבטוח
  Better Safe Than Sorry    Tel: 03-7966-561 :טל Fax: 03-7966-667 :פקס
   http://www.mvs.co.il             mailto:[EMAIL PROTECTED]  :דו"אל

 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry

================================================================To unsubscribe, 
send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to