On Fri, 2007-01-19 at 15:38 +1100, Del wrote:
> Peter Hardy wrote:
> 
> > Oh, cool. I seem to recall having problems with the "for file in *" 
> > construct, but I don't remember what they were, so I'll try it again 
> > next time I want a for loop.
> 
> The problem you'll have with "for file in *" is that when you have
> a ridiculously large number of files in a directory you will find
> that the maximum size of a command line is exceeded by "*".
> 
> So the way around that is, when you hit that problem, replace this:
> 
> for file in *; do
>    do_something_with $file
> done
> 
> with this:
> 
> ls | while read file; do
>    do_something_with $file
> done
> 
> ... the latter is a smudge less efficient, however.
> 
> -- 

Less efficient is OK... especially since there is likely to be a very
large number of files (100's?) so that may be a problem.

As to two files with the same timestamp, it will serve them right for
not keeping their distance.....   ;-)   

... but in reality, the files are being created sequentially by another
script with a 2 second sleep, so that *should* never happen.

Thanks everyone.. time to go test.

David.



-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to