removing a file with hyphens

Kaoru kaoru at slackwise.net
Thu Jun 7 11:45:03 BST 2007


Hey,

With most of the basic bash commands which take "--flag" style inputs
you can put "--" by itself to signify the end of your options and the
start of your list of files. The following should do it:

~$ rm -- -----Original

-- Alex

On 6/7/07, Paul Orrock <paulo at digitalcraftsmen.net> wrote:
> Hi,
>
> So for reasons I won't go into I ended up with a file like this
>
> -rw-r--r--   1 paulo paulo       0 2007-05-21 14:23 -----Original
>
> which I didn't want, so I tried the following :
>
> paulo at kryten:~$ rm *riginal
> rm: unrecognised option `-----Original'
> Try `rm --help' for more information.
> paulo at kryten:~$ mv '\-\-\-\-\-Original' old
> mv: cannot stat `\\-\\-\\-\\-\\-Original': No such file or directory
> paulo at kryten:~$ mv '-----Original' old
> mv: unrecognised option `-----Original'
> Try `mv --help' for more information.
> paulo at kryten:~$ mv \-\-\-\-\-Original old
> mv: unrecognised option `-----Original'
> Try `mv --help' for more information.
> paulo at kryten:~$ mv "\-\-\-\-\-Original" old
> mv: cannot stat `\\-\\-\\-\\-\\-Original': No such file or directory
> paulo at kryten:~$ rm '\-\-\-\-\-Original'
> rm: cannot remove `\\-\\-\\-\\-\\-Original': No such file or directory
>
> Then I tried unlink('-----Original') using perl and it worked fine.
>
> I'm glad that it did but I'm curious as to why ?
>
> My second question is how do non perl people do it ?
>
> So I thought I would ask you brainy people :-)
>
> Regards,
>
> Paul
>
>
>


More information about the london.pm mailing list