From owner-freebsd-questions@FreeBSD.ORG Fri May 12 15:29:57 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 88C6D16A78A for ; Fri, 12 May 2006 15:29:57 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B4FB43D45 for ; Fri, 12 May 2006 15:29:55 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.pc (aris.bedc.ondsl.gr [62.103.39.226]) (authenticated bits=128) by igloo.linux.gr (8.13.6/8.13.6/Debian-1) with ESMTP id k4CFTVM6032002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 12 May 2006 18:29:34 +0300 Received: from gothmog.pc (gothmog [127.0.0.1]) by gothmog.pc (8.13.6/8.13.6) with ESMTP id k4CFVg0H026068; Fri, 12 May 2006 18:31:42 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.pc (8.13.6/8.13.6/Submit) id k4CFVf8m026067; Fri, 12 May 2006 18:31:41 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 12 May 2006 18:31:41 +0300 From: Giorgos Keramidas To: Chuck Swiger Message-ID: <20060512153141.GA26040@gothmog.pc> References: <200605121450.k4CEokhn022089@dc.cis.okstate.edu> <20060512150608.GB25497@gothmog.pc> <4464A94C.6020606@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4464A94C.6020606@mac.com> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.396, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.80, BAYES_00 -2.60, DNS_FROM_RFC_ABUSE 0.20) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: Martin McCormick , freebsd-questions@freebsd.org Subject: Re: Trimming Whitespace From Beginning and end of Text Lines X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 May 2006 15:29:57 -0000 On 2006-05-12 11:27, Chuck Swiger wrote: >Giorgos Keramidas wrote: >> This fails to remove multiple occurences of the [[:space:]] class. >> >> There are at least the following ways: >> >> sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ... >> perl -pi -e 's/^\s*(\S.*\S)[ \t]*$/$1/' file ... >> >> The first one seems more straightforward to me most of the time, >> but there are times I find Perl's `-pi -e ...' idiom very convenient. > > It is, and I wish to acknowledge the above are entirely valid solutions > to the problem, but... > > python -c 'import sys; print sys.stdin.read().strip()' < file... > > ...has the advantage of being human readable. My old 300-baud accoustic > modem used to generate output which in hindsight looks astonishingly > close to regex character classes. :-) HEH! I see the joke about Perl being similar to "line noise" is not something local to our Greek IRC channels :)