tags:

views:

21

answers:

3

I want to get a ZSH list from a line-separated output. In my case, from the following command:

ssh myhost ls /Applications

I tried $(ssh myhost ls /Applications) but that doesn't work (it splits also at spaces).

A: 
${(ps.\n.)"$(ssh myhost ls /Applications)"}
ZyX
A: 

myarray=(${(f)"$(ssh myhost ls /Applications)"});

grddev
Correct in this case, but this will remove all empty lines, which is not always desirable for different commands' output.
Gilles
+1  A: 

lines=("${(@f)$(ssh myhost ls /Applications)}")

Gilles