Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!bionet!apple!sun-barr!decwrl!decvax!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.unix.wizards Subject: Re: Look! An xargs!! (Re: recursive grep) Message-ID: <680@lakart.UUCP> Date: 5 Sep 89 16:36:49 GMT References: <1122@virtech.UUCP> Organization: Lakart Corporation, Newton, MA Lines: 34 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@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+