xargs gives grep/gawk too much

Karr, David david.karr@wamu.net
Sat Dec 9 19:31:00 GMT 2006


If the point of this note is to get your pipeline to work, would it help
if you added something like "-n 30" to the xargs command?  This should
execute one instance of 'grep -l -e "error '1234567890'"' for every 30
lines of output from the previous pipe entry.

	$ echo path/* | \
		tr ' ' '\n' | \
		grep -v -e '\*' | \
		xargs -r grep -l -e "error '1234567890'" | \
		rest_of_pipe 

> -----Original Message-----
> From: cygwin-owner@cygwin.com 
> [mailto:cygwin-owner@cygwin.com] On Behalf Of Buchbinder, 
> Barry (NIH/NIAID) [E]
> Sent: Friday, December 08, 2006 10:05 AM
> To: cygwin@cygwin.com
> Subject: xargs gives grep/gawk too much
> 
> I get the following error message:
> 	xargs: grep: Argument list too long
> I've also gotten an equivalent error from xargs/gawk.
> 
> Of course, the whole idea of xargs is to avoid this error.  
> If I'm doing something wrong, I'd appreciate some hints of 
> what I am doing wrong or how to avoid this (other than "-s"). 
>  Otherwise, I suppose that this is a bug report.
> 
> The grep pipe, run under bash, that generates the error message is as
> follows:
> 
> 	$ echo path/* | \
> 		tr ' ' '\n' | \
> 		grep -v -e '\*' | \
> 		xargs -r grep -l -e "error '1234567890'" | \
> 		rest_of_pipe
> 
> Asking xargs to report on its limits:
> 
> 	$ echo path/* | \
> 		tr ' ' '\n' | \
> 		xargs --show-limits grep -e I_do_not_want_output
> 	Your environment variables take up 2174 bytes
> 	POSIX lower and upper limits on argument length: 2048, 1046528
> 	Maximum length of command we could actually use: 1044354
> 	Size of command buffer we are actually using: 34942
> 
> Everything should be up to date.  cygcheck.out is attached.  
> Let me know if you want any other information.
> 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list