Thanks for your responses guys. Both variations works as you said. Better yet, I understand why. Cheers! On Sun, Dec 18, 2016 at 11:08 PM, Bart Schaefer wrote: > On Dec 18, 8:02pm, Pablo Lalloni wrote: > } > } words=(${(z)$( } > } Which set words with the array of all the words in the file and that's > } great. > } > } lines=(${(f)$( } > } But then I get an array with just one string containing all the lines > } concatenated (no NLs). > > That's happening because $( spaces before (z) or (f) begin working. (z) doesn't care because it > splits on shell-syntax whitespace, but (f) has nothing to split on. > > To get what you want, you have to quote the $(...) substitution so the > NLs are preserved: > > lines=(${(f)"$( > That would be "more correct" in the (z) use as well, just in case the > line breaks were e.g. inside quoted strings that would change the shell > parse. (Not an issue with /proc/meminfo, of course, but in general.) > > } Note that if you split the last assignment in 2 steps, it works as > expected: > } > } lines=$( } lines=(${(f)lines}) > > There you've done first an assignment to a scalar, which preserves the > NLs as if $(...) were quoted. >