On 4 April 2011 03:53, erik quanstrom <quans...@quanstro.net> wrote: > i think this is what you want > > for(line in `{ifs=$nl cat}){...}
no, because that only sets ifs for the cat command, not for the `{} construct. ifs=$nl for (line in `{cat}) { ... } is perhaps what you meant to say. > but i have no idea why one would avoid the read > idiom. for large input, forking off a read for each > line keeps the memory footprint O(1). FWIW, i think that avoiding a read(1) loop is perfectly reasonable thing to want to do. a quick test i measured that calling read in shell loop was about 100 times slower than using `{}, and about 500 times slower than using awk to read the lines. in general, unless it was truly necessary, i would try to use awk or sed rather than use read(1) in a loop when i was going to deal with significantly sized input. when i've needed a "-n safe" version of echo in the past, i've used something like this: fn myecho {echo -n $"* ^ ' '}