[plug] grep + xargs = missing separator?

James Devenish devenish at guild.uwa.edu.au
Sat Sep 11 13:27:43 WST 2004


Hi Andrew,

In message <5c99ee27040910211745543c56 at mail.gmail.com>
on Sat, Sep 11, 2004 at 12:17:09PM +0800, Andrew Furey wrote:
> It seems the
> easiest way to fix it would be to run "echo --" before (or after) the
> grep process,

Is there a specific reason you aren't just using `grep -r`???
# grep -r -n -i -2 --binary-files=text "badmailfrom" /var/spool/exim/input

> # 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.

Xargs can only run a single command. I think you would have to create an
executable script containing the following:

#!/bin/sh
grep -n -i -2 --binary-files=text "badmailfrom" "$@" && echo --

Then, 

# find /var/spool/exim/input -print0 | xargs -0 /path/to/myscript

Alternatively, you could merge the above onto a single command line
by invoking the shell directly from xargs, but I am not confident to
construct the correct quoting without testing.







More information about the plug mailing list