Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Oct 2010 13:52:27 -0700
From:      Chip Camden <sterling@camdensoftware.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: [OT] writing filters in sh
Message-ID:  <20101028205227.GB45278@libertas.local.camdensoftware.com>
In-Reply-To: <20101028194012.8117.qmail@joyce.lan>
References:  <20101028160110.GA71713@guilt.hydra> <20101028194012.8117.qmail@joyce.lan>

next in thread | previous in thread | raw e-mail | index | archive | help

--rS8CxjVDS/+yyDmU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Quoth John Levine on Thursday, 28 October 2010:
> >I was hoping for a generalized, simple idiom for this, rather than
> >needing to implement it myself, for demonstration purposes
>=20
> ----------------------------------------
> #!/bin/sh
>=20
> cat "$@" |=20
> while read x
> do
>    echo "I saw $x"
> done
> ----------------------------------------
>=20
> Sheesh.
>=20
> R's,
> John
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.o=
rg"

<stage_direction>Smacks forehead as if starring in a V-8 commercial</stage_=
direction>=20

And of course, if the script does input in more than one place, you can
enclose the entire section in parentheses after the pipe:

cat "$@" | (
    read x
    ...
    read y
    ...
    select ans in a b c; do break; done
)

--=20
Sterling (Chip) Camden    | sterling@camdensoftware.com | 2048D/3A978E4F
http://camdensoftware.com | http://chipstips.com        | http://chipsquips=
.com

--rS8CxjVDS/+yyDmU
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iQEcBAEBAgAGBQJMyeKLAAoJEIpckszW26+RA4EIAJfTVR1EdOfRa0dOkknuP13r
bFpXEmhQVtavehozuUiYnDcFMW2DX5bFdL8L16xYZJ0bZIk5XXxqjKnFGkaq0MFF
Blp0wnqZe5EwTk8w7/xLQ9z6hjGAwqqmN1vti1S6BCmvnuw8xcuR4EgAOwlCHfro
1lPK3MVuhIs28rvwq8A2gXR6xGTpIdAtJSJpDKRok5TKbcBsAQOFhId7XJUuSwYY
sPR8+LwsFwqOHoerkTyML6uiatbCZAMez+9CWuJ/4RoavclhZANlnwo1L5NAHpfM
f61hoGLQnS/OH36OOXtfmK7C6vlpn0d9ZGhxiIbqPgphL71dmuXeezIhsi9WjYU=
=Hup6
-----END PGP SIGNATURE-----

--rS8CxjVDS/+yyDmU--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101028205227.GB45278>