Richard Lyons <[EMAIL PROTECTED]>: > On Thu, Nov 01, 2007 at 01:49:03PM -0700, Mike Bird wrote: > > On Thursday 01 November 2007 13:07, Wei Chen wrote: > > > I would like to write a bash script like the following one: > > > > > > for i in `some program that outputs a word list` > > > do > > > echo $i > > > done > > > > > > where the word list can be very very long. I wonder what is the upper > > > bound > > > limit of the length of word lists in "for" loop of a bash script, or > > > does it only > > > depend on the hardware (say, RAM)? Thank you in advance. > > > > Assuming that the words are output one per line, something > > like the following can handle lists of any size: > > > > some program | while read i; do echo $i; done > > A wild thought, but if you want to count the words in the output can you > not pipe it to wc? I haven't tried, this is just a thought...
Not wild at all. Most *ix apps (of the commandline variety, at least) are designed to expect input on their stdin if it's there. wc's no exception. "some_program | wc -l" will give you the number of lines of output produced by some_program. Exercise for you: play around with some_program | grep -c "some_string" which does the same thing, but only on lines you want to know about. -- Any technology distinguishable from magic is insufficiently advanced. (*) http://blinkynet.net/comp/uip5.html Linux Counter #80292 - - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]