[ale] xargs processes as input arrives?

JK jknapka at kneuro.net
Fri Apr 17 19:09:14 EDT 2009


One approach might be to use "xargs -n 1".  That way it would be
constrained to issue a separate grep command for each filename
produced by "ls -tr".  I am thinking that maybe grep is not fussy
about the order in which it processes its file args. I can't
find any statement in the manpage that it necessarily does them
left-to-right. (Though it seems perverse not to.)

-- JK


Jeff Lightner wrote:
> I’ve always assumed xargs processed each item as it arrived but saw 
> something today that made me think perhaps this isn’t the case.
> 
>  
> 
> In essence I’m doing an “ls –tr log.* |xargs grep –hA 30 sometext”
> 
>  
> 
> Files are log, log.1, log.2 … log.10 where log is the newest and log.10 
> is the oldest.  
> 
>  
> 
> My subsequent processing relies on the information from log.10 appearing 
> first then log.9 then log.8 … log.
> 
>  
> 
> What I saw today made it look as if it somehow grabbed log.10 at the end 
> instead of the beginning.  
> 
>  
> 
> Apparently they were doing some tweaking of logs today so it’s possible 
> what I saw was a result of them moving something.  
> 
>  
> 
> I’d just like confirmation that xargs does in fact process things (and 
> display it) in the order of what is piped into it rather than buffering 
> it all and deciding on its own order.  
> 
>  
> 
> Nothing in the man page seems to directly answer question about order.
> 
>  
> /Please consider our environment before printing this e-mail or 
> attachments./
> ----------------------------------
> CONFIDENTIALITY NOTICE: This e-mail may contain privileged or 
> confidential information and is for the sole use of the intended 
> recipient(s). If you are not the intended recipient, any disclosure, 
> copying, distribution, or use of the contents of this information is 
> prohibited and may be unlawful. If you have received this electronic 
> transmission in error, please reply immediately to the sender that you 
> have received the message in error, and delete it. Thank you.
> ----------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale


-- 
A closed mouth gathers no feet.


More information about the Ale mailing list