Date: Thu, 28 Oct 2010 10:01:10 -0600 From: Chad Perrin <perrin@apotheon.com> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: [OT] writing filters in sh Message-ID: <20101028160110.GA71713@guilt.hydra> In-Reply-To: <20101028151148.GB73337@libertas.local.camdensoftware.com> References: <20101027212841.GA67716@guilt.hydra> <20101028151148.GB73337@libertas.local.camdensoftware.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 28, 2010 at 08:11:48AM -0700, Chip Camden wrote: >=20 > Here's a way to do what you're wanting to do. Unfortunately, it isn't a > generalized, single construct: >=20 > #!/bin/sh > if [ $# -ge 1 ];then > exec cat $@ | $0 > exit > fi >=20 > while read data; do > echo $data > done >=20 > My lame attempts to generalize the first paragraph into an alias, > function, or shell script have met with disappointment. I was hoping for a generalized, simple idiom for this, rather than needing to implement it myself, for demonstration purposes (and for easy reuse later, of course). Your solution does not exactly fit my preferences for simplicity, but I might include it in an article I'm writing anyway. It's simple and readable enough that it should not clutter up the article much. I tested it for some simple use cases, and it works well. Thanks for saving me a little trouble. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --AhhlLboLdkugWU4S Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkzJnkYACgkQ9mn/Pj01uKWoTwCdG7yHo0w5ocwBe0OEqxVMQf/b ScoAoLrRqWUQlmg8SXBrns5rlflEkOHE =MFcz -----END PGP SIGNATURE----- --AhhlLboLdkugWU4S--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101028160110.GA71713>