Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: sed/vi how to concatenate all non-empty lines?



Update,

col and the script you provided work fined, except that it removed all blank 
lines :) I was hoping to keep the blank lines as they separated the 
paragraphs from each other . . .

Jc

>From: OZAWA -Crouton- Sakuro <crouton@example.com>
>Reply-To: tlug@example.com
>To: tlug@example.com
>Subject: RE: sed/vi how to concatenate all non-empty lines?
>Date: Wed, 25 Jul 2001 13:09:43 +0900
>
>At Wed, 25 Jul 2001 03:39:18 +0000,
>Jean-Christian Imbeault wrote:
>
> > So how to I get sed or vi to concatenate all lines within a paragraph 
>into
> > one linebut keep the empty lines between paragraphes? (i.e. concatenate 
>all
> > consecutive non-empty lines together)?
>
>$ cat -s input.txt | sed join.sed
>
>join.sed is: BEGIN--cut here--cut here
>#n
>
>/^ *$/!{
>	H
>}
>/^ *$/{
>	x
>	s/\n/ /g
>	s/^ //
>	p
>}
>${
>	x
>	s/\n/ /g
>	s/^ //
>	p
>}
>END--cut here--cut here
>
>Don't forget '#n', or use 'sed -n' instead.
>
>--
>OZAWA -Crouton- Sakuro
>E-Mail: mailto:crouton@example.com
>    Web: http://www.weatherlight.org/~crouton/
>    PGP: C98F 74E0 AEEB 4578 1DFC  F650 3BE0 9627 11FC C9F5
>VERBA VOLANT, SCRIPTA MANENT
>
>-----------------------------------------------------------------------
>Next Nomikai Meeting:    Fri, Aug 10 19:30-  Tengu Tokyo Eki-Mae
>Next Technical Meeting:  Sat, Sep ?? 13:30-  Akasaka Kumin Center
>-----------------------------------------------------------------------
>more info: http://www.tlug.gr.jp           Sponsor: Global Online Japan
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links