Look! An xargs!! (Re: recursive grep)

Bob McGowen Wyse Technology Training bob at wyse.wyse.com
Thu Sep 7 05:03:15 AEST 1989


In article <1126 at virtech.UUCP> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>In article <16816 at pasteur.Berkeley.EDU>, deboor at buddy.Berkeley.EDU (Adam R de Boor) writes:
>> 
---deleted---
>> while read arg; do
>> 	args="$args $arg"
>> done
---deleted---
>
>Yet another non-solution.  This one does not handle the problem where the
>list of arguments exceeds the maximum length (usually 5120 bytes). 

true, but a test could be added to avoid this problem.  As a quick and
not too efficient solution:

	if [ `echo $args|wc -c` -gt 3000 ]
	then
	    $* $args
	fi
A final product would require better checking, I think, and testing of
command line items, etc, but this would seem to be a way to start.

>Also there is a dependency that the args variable in the while loop is 
>available outside the loop.  I have found that this is not always true 
>due to the fact that the while loop may be implemented using a sub-shell.

ONLY when the loop's input or output is redirected to/from other programs or
a file.  If this is not the case the loop will always execute in the current
shell.  Thus the form in the example is quite valid.

>I guess we need a post-graduate level course, or a beginners c program class.

OK, but are you willing to pay for it?

Bob McGowan  (standard disclaimer, these are my own ...)
Customer Education, Wyse Technology, San Jose, CA
..!uunet!wyse!bob
bob at wyse.com



More information about the Comp.unix.wizards mailing list