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

Re: rm difficult filename



"Kevin B. McCarty" <kmccarty@Princeton.EDU> (Wed, 08 Sep 2004 08:31:39 -0400) writes:

> John Summerfield wrote:
>
>> Often, too, you can use the TAB key to advance over problematic characters, a "?" to represent one of them and "*" to represent any number of them. So
>> 
>> rm ?rtsp-stream-over-tcp
>> rm *over-tcp
>
> Sometimes, but in this case it wouldn't work.  Using a * or ? will help
> with characters that the shell wants to mess with, but - generally has
> no special meaning to the shell. [1]
>
> So "rm *over-tcp" will be globbed by the shell and passed to rm as
> "rm -rtsp-stream-over-tcp".  This doesn't help because the first - is
> interpreted by rm itself as an indication that the argument is a flag
> instead of a file.

One solution here is to just prefix the file name with a directory
name. For example:

$ rm ./-xfff
works without a problem.

>
> Some people take advantage of this behavior by creating a file called
> "-i" in important directories, so "rm *" will turn into "rm -i ..."
> causing rm to ask for confirmation before deleting.
>
>
> [1] Yes, I'm aware of "cd -" and there are probably other special cases.
>
> regards,
>
> -- 
> Kevin B. McCarty <kmccarty@princeton.edu>   Physics Department
> WWW: http://www.princeton.edu/~kmccarty/    Princeton University
> GPG public key ID: 4F83C751                 Princeton, NJ 08544

-- 
"Man is distinguished from all other creatures by
the faculty of laughter."
- Joseph Addison



Reply to: