find, xargs and spaces

Brian Dessent
Fri Jul 4 19:03:00 GMT 2008

Fergus wrote:

> fails.) (There are probably alternative ways of attacking this specific
> problem that avoid the -print0 .. -0 .. but I would be interested in a
> general solution.)

In the general case, you just have to ensure that whatever's in front of
xargs in the pipeline outputs null delimited records, and if it doesn't
insert something in the pipeline that will, such as perl -pe
's,\n,\0,'.  Of course, this means that you can't process files that
contain newlines in their names, but if the previous utility in the
pipeline can't natively emit null-delimited output then you've already
lost that battle and it's impossible to recover.

In this specific case however, just use grep -Z.

> I know this is not Cygwin-specific but if there is a simple answer I
> would really appreciate the help.

Of course it's not.  Don't you think the fileutils list would be a
better place?


More information about the Cygwin-talk mailing list