From owner-freebsd-questions@FreeBSD.ORG Thu Oct 28 17:53:04 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA5CF1065674 for ; Thu, 28 Oct 2010 17:53:04 +0000 (UTC) (envelope-from vogelke@hcst.net) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id 6F4CF8FC18 for ; Thu, 28 Oct 2010 17:53:04 +0000 (UTC) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o9SHr3p1015792 for ; Thu, 28 Oct 2010 13:53:03 -0400 Received: (from vogelke@localhost) by beta.hcst.com (8.14.3/8.14.3/Submit) id o9SHr3W0015791; Thu, 28 Oct 2010 13:53:03 -0400 Received: by kev.msw.wpafb.af.mil (Postfix, from userid 32768) id 21E2CBF81; Thu, 28 Oct 2010 13:51:42 -0400 (EDT) To: freebsd-questions@freebsd.org In-reply-to: <20101028161712.GC73337@libertas.local.camdensoftware.com> (message from Chip Camden on Thu, 28 Oct 2010 09:17:12 -0700) Organization: Array Infotech X-Disclaimer: I don't speak for the USAF or Array Infotech. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 References: <20101027212841.GA67716@guilt.hydra> <20101028151148.GB73337@libertas.local.camdensoftware.com> <20101028160110.GA71713@guilt.hydra> <20101028161712.GC73337@libertas.local.camdensoftware.com> Message-Id: <20101028175142.21E2CBF81@kev.msw.wpafb.af.mil> Date: Thu, 28 Oct 2010 13:51:42 -0400 (EDT) From: vogelke+unix@pobox.com (Karl Vogel) Subject: Re: [OT] writing filters in sh X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: vogelke+unix@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Oct 2010 17:53:04 -0000 >> On Thu, 28 Oct 2010 09:17:12 -0700, >> Chip Camden said: C> Perhaps someone with more sh fu can transform the 'if' paragraph into a C> one-liner at least. When I tried to do so, I got an unexpected ; error. Try this: #!/bin/sh test $# -ge 1 && cat $@ | exec $0 && exit 0 IFS=$'\n' while read data; do echo "$data" done exit 0 Resetting IFS is only necessary if you want to preserve whitespace in each line. Putting $data in quotes prevents any shell metacharacters from being expanded. -- Karl Vogel I don't speak for the USAF or my company Sign in a New York drugstore: "We dispense with accuracy"