Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Reading output into variables



I don't know of a way to split it into separate variables exactly, but
you could use

FOO=($(program))

and then

"$FOO[1]" would be "a" and "$FOO[2]" would be b

Tj




On Mon, Apr 7, 2014 at 10:20 AM, Yuri D'Elia <wavexx@xxxxxxxxxx> wrote:
> Maybe a stupid question, but is there a way to read the output of a
> program and split into variables _conveniently_ using the IFS?
>
> To clarify, I would the something as convenient as:
>
> program | read a b
>
> minus the subshell.
> Note that I actually did the following:
>
> program | { read a b; hooray }
>
> when I could, so this "solution" doesn't count.
> Bonus points if that's something that would also work in bash.
>



Messages sorted by: Reverse Date, Date, Thread, Author