[lug] Those Pesky Newlines

Peter Hutnick peter-lists at hutnick.com
Thu Dec 26 22:11:11 MST 2002


Joseph P. Crotty said:
>> Is there an obvious way to strip "line wrap" newlines while leaving
>> "paragraph separating" newlines intact?
>
> What defines start of "paragraph"?

I'm actually worried about the end of a paragraph, which I take to be a
line (which, by definition ends with a newline, unless, maybe, it is the
last line of the file) followed by a line that consists solely of a
newline.

>> IOW, I need to strip all the
>> newlines out of a file *except* ones on their own line and ones that
>> are on a line with text that is followed by a line that consists only
>> of a newline.

Hmm. I seem to be repeating myself.

> We talking unix or M$ files (i.e. define the newline character please?)
> Better yet, how about a sample file we can tinker with?

Are you seriously asking me this?  Yes UNIX.  By newline character I mean
the newline character.  As opposed to, say, a carriage return character
followed by a newline character.

I think I have figured it out.  Remove any newlines that aren't the first
character on a line, then replace all remaining newlines with two
newlines.

-Peter





More information about the LUG mailing list