On Tue, Aug 29, 2000 at 08:32:10PM +1100, Scott Howard wrote:
> A number of other options have been given, but this one will work on
> all occasions on all (?) platforms :
> 
> find /base/dir/name -type f -print | sed 's/ /\\ /g' | xargs rm -f

Nope, try:

$ mkdir foo
$ touch 'foo/bad\file'
$ touch 'foo/bad\ file'
$ touch 'foo/bad$USER'

If you insist on traditional find arguments, then I think that
the "-exec baz \{\} \;" semantics will work for most things, but
will be slower than "-print0 | xargs -0 baz" for most operations,
because it has to fork to execute function for every single
file.  Xargs will pass a whole bunch of filenames to baz at a
go.

\{\} \; is also ugly as sin.

For the original question, I agree that rm -rf foo; mkdir foo is
probably the best answer of all.

I agree that those file names are stupid, but we're building
scripts here with the intention that they _dont_ break, right?

You're living in a land where file names are entered into
innocent-looking GUIs, which positively _invite_ the unwary user
to put all sorts of stupid things in there.  They're even given
the examples: "My Files", "Program Files", etc...

-- 
Andrew


--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to