[plug] grep + xargs = missing separator?

Andrew Furey Andrew.Furey at gmail.com
Sat Sep 11 12:17:09 WST 2004


On Thu, 9 Sep 2004 17:08:29 +0800, Cameron Patrick
<cameron at patrick.wattle.id.au> wrote:
> I presume that they'd be because when the argument list gets too long,
> xargs has to run multiple grep processes, and grep doesn't output the
> separators at the end of a run?

Yes, on further investigation that seems to be it. It seems the
easiest way to fix it would be to run "echo --" before (or after) the
grep process, within the xargs call, something like

# find /var/spool/exim/input -name \* | xargs echo --; grep -n -i -2
--binary-files=text "badmailfrom"

Except that this doesn't work because xargs only deals with the echo
command, then the grep runs on its own.

Is there any way to get around this, maybe some xargs parameter (I
don't see anything)? I could always use --max-chars (or whichever
limit is being hit) but I'd rather it scaled better.

The alternative would be to call grep individually for each file
returned by a perl glob(), but that's nasty for obvious performance
reasons...

Andrew

-- 
Linux supports the notion of a command line or a shell for the same
reason that only children read books with only pictures in them.
Language, be it English or something else, is the only tool flexible
enough to accomplish a sufficiently broad range of tasks.
                          -- Bill Garrett



More information about the plug mailing list