[plug] grep + xargs = missing separator?

Cameron Patrick cameron at patrick.wattle.id.au
Thu Sep 9 17:23:35 WST 2004


James Devenish wrote:

> In message <20040909090829.GB29387 at cp.yi.org>
> on Thu, Sep 09, 2004 at 05:08:29PM +0800, Cameron Patrick 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?
> 
> (1) To Cameron: is that a bug if it doesn't print those separators?

Not a bug in grep :-) just in the way it's being used.

> Are the separators just text at the end of lines in the source
> files? I don't quite know what's going on, yet :)

No, they're being printed by grep, because it's printing multiple
lines of context for each file.  Grep prints "--" lines between files
and only between files.  Example:

$ for x in a b c; do echo "line one\nline two\nline three" >$x; done
$ grep -2 line a b c
a:line one
a:line two
a:line three
--
b:line one
b:line two
b:line three
--
c:line one
c:line two
c:line three

Cameron.




More information about the plug mailing list