Albert
Albert

Reputation: 68140

get list from line-separated output

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).

Upvotes: 3

Views: 462

Answers (3)

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

Upvotes: 2

grddev
grddev

Reputation: 2842

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

Upvotes: 0

ZyX
ZyX

Reputation: 53614

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

Upvotes: 0

Related Questions