Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Dec 2019 21:04:46 -0000 (UTC)
From:      Christian Weisgerber <naddy@mips.inka.de>
To:        freebsd-questions@freebsd.org
Subject:   Re: Counter in sh inside loop, value "encapsulation"
Message-ID:  <slrnquis7e.1olt.naddy@lorvorc.mips.inka.de>
References:  <20191204181300.8dd0e03c.freebsd@edvax.de> <slrnqug5mi.srf.naddy@lorvorc.mips.inka.de> <20191205133521.28cb5ac4@gumby.homeunix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2019-12-05, RW via freebsd-questions <freebsd-questions@freebsd.org> wrote:

> IIRC when this sort of thing came once before someone posted a way of
> processing the output of a pipeline and having multiple variables
> directly accessible to the main script. 
>
> It didn't involve creating files or sockets, or storing the output of
> the pipeline in a single variable. There was some trick that avoided
> last stage being done in sub-shell.

Instead of

  cmd | while read var; do ...; done

you can use

  while read var; do ...; done <<EOF
  $(cmd)
  EOF

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?slrnquis7e.1olt.naddy>