Text formating

J. Erik Hemdal ehemdal at townisp.com
Tue Apr 27 01:54:54 UTC 2004



> On Mon, Apr 26, 2004 at 09:48:12AM -0500, Bill Gradwohl wrote:
> > I'm looking for a utility that will change:
> >
> > Mary had a\n
> > little\n
> > lamb, it's fleece was white\n
> > as snow.\n
> >
> > To:
> >
> > Mary has a little lamb, it's fleece was white as snow.
> >
> > Further, I'd like it to recognize the period at the end of a sentence as
the
> > only possible place where a new line might be appropriate as a separator
> > before the next paragraph.
> >
> > What I'm trying to do is format pages of text that have arbitrary
newline
> > characters at position 72 and remove all of them except the ones that
> > separate paragraphs. The fmt utility can fix up the sentence above, but
it
> > inserts newlines of its own.
> >
> > Does such a utility exist?

If you are able to use Perl, you can do it yourself.  Perhaps this script
will either do what you need or give you enough to tailor it for your
specific purpose
#! /usr/bin/perl

use warnings;

use strict;

my $line;

$/='.';

while ($line=<>) {

    $line =~ s/\n/ /g;

    $line =~ s/ {2,}/ /;

    $line =~ s/^ //;

    print "$line\n";

}

Erik







More information about the fedora-list mailing list