Look! An xargs!! (Re: recursive grep)
David Goodenough
dg at lakart.UUCP
Wed Sep 6 02:36:49 AEST 1989
OK - will you all get off my case, already!!
#! /bin/sh
awk 'BEGIN {
command = "'$1'"
rec = command
}
{
for (i = 1; i <= NF; i++)
{
if (length(rec " " $i) > 512 && rec != command)
{
print rec
rec = command
}
rec = rec " " $i
}
}
END {
if (rec != command)
print rec
}'
The 512 can be changed to match the limits of whatever you want - it could
even be made a second parameter to this grungy little shell script. Or if
you want to make command everything else on the invocation line:
xargs grep -i foobar
type of thing, then the $1 in the BEGIN section can be changed to $*
So there :-P Like I said, I do it all with awk :-)
--
dg at lakart.UUCP - David Goodenough +---+
IHS | +-+-+
....... !harvard!xait!lakart!dg +-+-+ |
AKA: dg%lakart.uucp at xait.xerox.com +---+
More information about the Comp.unix.wizards
mailing list