can't delete a file called -cr

can't delete a file called -cr

Post by Computer Perso » Fri, 28 Feb 2003 07:33:10



Trying to remove a file with a name of:  -cr

If I do a "rm -i *" I get an error because it is trying to use the "-c" as
an option on the rm command.

Any ideas?

Thanks

 
 
 

can't delete a file called -cr

Post by Nicholas Drone » Fri, 28 Feb 2003 09:12:49


CP> Trying to remove a file with a name of:  -cr

CP> If I do a "rm -i *" I get an error because it is trying to use the "-c" as
CP> an option on the rm command.

Use '--' to indicate that there are no more command flags to
process:

$ ls -l -- -cr
-rw-r--r--   1 ndronen  food              0 Feb 26 17:11 -cr
$ rm -- -cr
$ ls -l -- -cr
ls: 0653-341 The file -cr does not exist.

--
"Why shouldn't I top-post?"    http://www.aglami.com/tpfaq.html
"Meanings are another story."  http://www.ifas.org/wa/glossolalia.html

 
 
 

can't delete a file called -cr

Post by Tom Hoffman » Fri, 28 Feb 2003 10:04:30




> CP> Trying to remove a file with a name of:  -cr

> CP> If I do a "rm -i *" I get an error because it is trying to use the
> "-c" as CP> an option on the rm command.

> Use '--' to indicate that there are no more command flags to process:

> $ ls -l -- -cr
> -rw-r--r--   1 ndronen  food              0 Feb 26 17:11 -cr $ rm -- -cr
> $ ls -l -- -cr
> ls: 0653-341 The file -cr does not exist.

how about:

rm -i "-cr"

or

find . -name "-cr" -exec rm -f {} \;

 
 
 

can't delete a file called -cr

Post by computer perso » Fri, 28 Feb 2003 11:22:37


Amazing! Thanks. Worked like a charm. How the heck did you know that?



> CP> Trying to remove a file with a name of:  -cr

> CP> If I do a "rm -i *" I get an error because it is trying to use the
"-c" as
> CP> an option on the rm command.

> Use '--' to indicate that there are no more command flags to
> process:

> $ ls -l -- -cr
> -rw-r--r--   1 ndronen  food              0 Feb 26 17:11 -cr
> $ rm -- -cr
> $ ls -l -- -cr
> ls: 0653-341 The file -cr does not exist.

> --
> "Why shouldn't I top-post?"    http://www.aglami.com/tpfaq.html
> "Meanings are another story."  http://www.ifas.org/wa/glossolalia.html

 
 
 

can't delete a file called -cr

Post by Nicholas Drone » Fri, 28 Feb 2003 13:57:32





>> CP> Trying to remove a file with a name of:  -cr

>> CP> If I do a "rm -i *" I get an error because it is trying to use the
cp> "-c" as
>> CP> an option on the rm command.

>> Use '--' to indicate that there are no more command flags to
>> process:

>> $ ls -l -- -cr
>> -rw-r--r--   1 ndronen  food              0 Feb 26 17:11 -cr
>> $ rm -- -cr
>> $ ls -l -- -cr
>> ls: 0653-341 The file -cr does not exist.

cp> Amazing! Thanks. Worked like a charm. How the heck did you know that?

A few years of experience is usually enough to pick up useful
little tricks here and there.

Also, please don't top-post.  (See URL below.) :-)

--
"Why shouldn't I top-post?"    http://www.aglami.com/tpfaq.html
"Meanings are another story."  http://www.ifas.org/wa/glossolalia.html

 
 
 

can't delete a file called -cr

Post by Jose Pina Coelh » Tue, 04 Mar 2003 07:53:44



> Amazing! Thanks. Worked like a charm. How the heck did you know that?

The most standard way of reading the arguments from inside a program
will do some extended processing for identifying flags.  As part of that
processing, it will recognize '--' as "from this place on there are no
more flags".

Incidentaly, trying rm -f * is very dangerous (because you can have
files with special characters on them).

Demo:
# echo > '-rf ..'
"rm *" will expand to "rm -rf .. remaining files"

To avoid this sort of expansion, rm won't touch '..', but the ingenuity
of fools is never to be underestimated.

Always: rm -- *

--
Doing AIX support was the most monty-pythonesque
activity available at the time.
Eagerly awaiting my thin chocolat mint.

 
 
 

can't delete a file called -cr

Post by Spooge Geck » Wed, 05 Mar 2003 14:56:57


/bin/rm \-cr


IT in comp.unix.aix ,. And  promptly posted it on the wall in the
Men's Room of Habib's Middle  Eastern cafe and auto upholstry shop  

Quote:>Trying to remove a file with a name of:  -cr

>If I do a "rm -i *" I get an error because it is trying to use the "-c" as
>an option on the rm command.

>Any ideas?

>Thanks

vidi venci veni

F R E E     T I B E T
(Applies to first 2, all others at regular price)