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>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] 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 > > ---------------------------------------- > #!/bin/sh > > cat "$@" | > while read x > do > echo "I saw $x" > done > ---------------------------------------- > > Sheesh. > > 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.org" <stage_direction>Smacks forehead as if starring in a V-8 commercial</stage_direction> 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 ) -- Sterling (Chip) Camden | sterling@camdensoftware.com | 2048D/3A978E4F http://camdensoftware.com | http://chipstips.com | http://chipsquips.com [-- Attachment #2 --] -----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-----help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101028205227.GB45278>
