Date: Fri, 12 May 2006 18:31:41 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Chuck Swiger <cswiger@mac.com> Cc: Martin McCormick <martin@dc.cis.okstate.edu>, freebsd-questions@freebsd.org Subject: Re: Trimming Whitespace From Beginning and end of Text Lines Message-ID: <20060512153141.GA26040@gothmog.pc> In-Reply-To: <4464A94C.6020606@mac.com> References: <200605121450.k4CEokhn022089@dc.cis.okstate.edu> <20060512150608.GB25497@gothmog.pc> <4464A94C.6020606@mac.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2006-05-12 11:27, Chuck Swiger <cswiger@mac.com> 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 :)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060512153141.GA26040>