Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Reading output into variables
- X-seq: zsh-users 18704
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: "Yuri D'Elia" <wavexx@xxxxxxxxxx>
- Subject: Re: Reading output into variables
- Date: Mon, 7 Apr 2014 11:16:34 -0400
- Cc: Zsh-Users List <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=s5y/kFwky7m88B4sJP/U7CwtqzU1fqt2f1whHgYUCWk=; b=q12ckrSsZKJupHhzvjMLeNTOjTkEvjfoSkBrsu7rDTPgSuFg8A8jZDVnTUU2iLllye 54QRVCQwaM1NLFilg8s4g+dV6YIg7OkmifWMxn+JvAXUVA9Y9Wty7y+XgdSu9yWKlVtl FTq7lpZvsqXXE6Q9tioxfTko+s18qiF65mEt15IqjrTY8LKUXQfvBrd0lkaIbP6vJFB2 Ih5LokJ0F0Nvki+Uo/gqOnaTFerFX9Ew8WcOk5xFQ65VNqKpIm5KFYmUH1KJ4OCI5+DD sIoUYgMiW5IzFj68r8ABqTeJVW7lfBqRKkHqfil1QmIAFwvwGWJopt9FbdnzXLIcCnlt upYg==
- In-reply-to: <lhuc74$rjf$1@ger.gmane.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <lhuc74$rjf$1@ger.gmane.org>
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