removing a file with hyphens

Nicholas Clark nick at ccl4.org
Thu Jun 7 14:43:25 BST 2007


On Thu, Jun 07, 2007 at 02:13:42PM +0100, David Cantrell wrote:
> On Thu, Jun 07, 2007 at 01:50:14PM +0100, Jonathan Stowe wrote:
> > On Thu, 2007-06-07 at 13:20 +0100, Matt Wilson wrote:
> > > > #  find . -name '*Original' -exec rm {} \;
> > > ARGH!
> > Yeah, could have at least used the '-delete' action of 'find' to save
> > the potential deaths of thousands of angels/fairies/kittens/(whatever it
> > is that dies when you fork).
> 
> It's easier to test the -exec version:
> 
>   find . -name foo\* -exec echo rm {} \;
> 
> to make sure you're deleting the right stuff.  Additionally, -delete
> seems to be a GNUism.  At least, it's not documented on the NetBSD box
> whose find manpage I just looked at.
> 
> xargs -n is what you want if you want to be kind to angels/fairies/
> kittens.

Whilst everything you type is correct, as are the two previous posters,
considering the original question (now lost in the mists of topic drift),
using find just seems to be a very fancy way of engineering a path starting
with ./ to avoid rm thinking that a file name starting with a hyphen is an
option.

Nicholas Clark


More information about the london.pm mailing list