Stripping "hard returns" from UNIX mail files

Peter Renzland peter at ontmoh.UUCP
Mon Oct 29 17:44:31 AEST 1990


patrick at casbs.Stanford.EDU (Patrick Goebel) asks for a UNIX utility
to remove "hard returns" from mail messages for subsequent processing
by MS-DOS wordprocessors.

Unix considers it natural for text to be made up of lines, and all
programs that do useful things with text assume that such lines are
within some reasonable limit.  This corresponds to things that naturally
contain lines (text in books or on your display, or on typewriter, or
a line printer), and those things, naturally, have limits on the line
length.

The RETURN key, and its code, is an implementation of the typewriter's
"carriage" return.

Text which is thus made up of lines can easily be formatted in all sorts
of ways.  But, if we format it so that we have (limitless) multiline
paragraphs and no longer any line separators, some of our programs that
are so handy with lines of text may break in the face of possibly huge
paragraphs.

Having said that, you could try something like this little program:

awk '
NF==0	{ if(LINE) { print LINE ; LINE="" } ; print ; next}
	{ if(LINE) LINE=LINE " " $0 ; else LINE=LINE $0 }
END	{ print LINE }
' $*

I would prefer to use the PC wordprocessor's text import facilities to
take standard line-oriented text and convert it to its own paragraph
format.

-- 
Peter Renzland @ Ontario Ministry of Health  416/964-9141  peter at ontmoh.UUCP



More information about the Comp.unix.questions mailing list