Re: deleting files with odd names



On 25 Jul., 19:20, ld50...@xxxxxxxxx wrote:
Somehow, I have acquired a couple of files whose names start with "-",
and I can't delete them, at least not with the usual "\" escape
character. For example, one file is called "-h.gif" and when I try to
delete it I see:

rm '-h.gif'

rm: invalid option -- h

rm '\-h.gif'

rm: cannot lstat `\\-h.gif': No such file or directory

What's the correct escape character for this?

Thanks,

Joe

Hmm, '-' should be char 0x2D, try escape sequence \055 (octal). How
about double quotes? Maybe that helps. Or just use "rm ?h.gif", if
that doesn't match any other names.

Regards,
Eric

.



Relevant Pages

  • Re: A critique of cgi.escape
    ... and quotes should always be escaped. ... Making cgi.escape always escape the '"' character would not break ... and would probably fix a few bugs in existing code. ...
    (comp.lang.python)
  • Re: escaped identifier vs regular names ?
    ... Escaped identifiers are not in a separate namespace from normal ... the terminating whitespace character to be a space character, ... And, yes, many Verilog tools create escaped names of this form. ... escape names, it isn't really handling the entire Verilog language. ...
    (comp.lang.verilog)
  • Re: Unrecognized escape sequences in string literals
    ... character without knowing the context, ... '\n' maps to the string chr. ... In both cases the backslash in the literal have the same meaning: ... escape every backslash, ...
    (comp.lang.python)
  • Re: Unrecognized escape sequences in string literals
    ... a reader can't know if \ is a literal character or escape character ... without knowing the context, and it means an innocuous change in context ... thinking about the fact that the s comes after the backslash. ...
    (comp.lang.python)
  • Re: problems with opening files due to files path
    ... GUI or it is a console app. ... of what an escape character and escape sequence is. ... character) inside a string specially, it makes the character after the ...
    (comp.lang.python)