Trimming Whitespace From Beginning and end of Text Lines
Chuck Swiger
cswiger at mac.com
Fri May 12 09:09:59 PDT 2006
Giorgos Keramidas wrote:
> On 2006-05-12 11:27, Chuck Swiger <cswiger at mac.com> wrote:
>
>> 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 :)
Indeed. :) I must confess that it doesn't do in-place replacement of
the files, though. I'd have to do a two-liner, I guess:
python -c 'import sys,fileinput
for line in fileinput.input(inplace=1): print line.strip()' file1
file2 ...
--
-Chuck
More information about the freebsd-questions
mailing list