ken yap wrote:
> I hope you understand why. ./ is not an escape code. It’s just a way of
> making sure that the first character of the argument is not -.
Q: would
rm ?ioP
do it also?
however, if i were gonna do that i’d first do
ls ?ioP
to see if maybe their might also be in that directory some files i
wanted to keep, like:
The answer depends on whether ? substitution happens before grep sees the argument. What do you think?
Incidentally another way of doing it is:
rm – -ioP
where the – signifies end of options and after that - is not significant as the first character. And both methods are explained in the man page for rm.
ken yap wrote:
> The answer depends on whether ? substitution happens before grep sees
> the argument. What do you think?
hmmmmm…(see, i’m not a real guru and i therefore didn’t know) does
grep have a chance to get in the act if the following is issued:
rm ?ioP
are you saying that the rm command (“behind the scenes”) first calls
grep to filter the list to act on and then performs the remove
actions?? interesting…
> Incidentally another way of doing it is:
>
> rm – -ioP
thanks, read that and promptly forgot it…
(maybe it will ‘stick’ now)
@palladium: the ‘grep’ probably was from the original command. I’ve done ‘greps’ redirected to a filename which was based on the expected result of the ‘grep’. One result was a filename beginning with “-” since there were no results from ‘grep’. IIRC I was able to move the -file to a new folder, then removed the folder by force( too lazy for ‘man rm’, thinking I knew all that…).
having just reviewed the last few i am now more confused than ever…
i think the answer to my question would
rm ?ioP
do the same as your
rm ./-ioP
would be "yes, if used alone (as did the OP) and not pipelined in with
grep (or other commands) which might jumble it…or, in other words
your would always work (and is therefor the better way)
am i right? and i will say: thanks for the better way which will
always work!!
No, as I said, the shell will expand ?ioP to -ioP and this is what rm will see and treat the filename as options rather than a file to remove. Try this: