AWK experts - how would I code around this in awk...

Steve Flynn anothermindbomb at gmail.com
Sun Feb 21 10:45:16 UTC 2010


On Fri, Feb 19, 2010 at 2:35 PM, Karl Auer <kauer at biplane.com.au> wrote:
> On Fri, 2010-02-19 at 13:35 +0000, Dave Howorth wrote:
>> Here's another perl version:
>>
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>>
>> local $/ = '';
>> my $text = <>;
>>
>> $text =~ s/\n//g;
>> $text =~ s/(.{20})/$1\n/g;
>>
>> print $text;
>
>
> Cool! But:

Indeed. A perl version of the bash script suggested by Alex.

>  - it reads the entire contents of stdin into memory

This might be an issue. This AIX box does have 128 gig of RAM but
there's also other software running on this machine (notably half of
an Oracle RAC cluster which hosts several databases with 50 Gb
allocated to at least one of them.

>  - there may be problems with arbitrarily large variables
>  - a partial last record will not be terminated with a newline
>  - it doesn't handle blank lines

There may well be blank lines, especially where a data entry clerk has
elected to space the text out with a couple of "enter enter enter"
lines.

-- 
Steve
When one person suffers from a delusion it is insanity. When many
people suffer from a delusion it is called religion.

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0




More information about the ubuntu-users mailing list