Mailing List Archive


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

Re: [tlug] sed or perl script help please . . .



You can use awk:

BEGIN { current = 1;
        text="";
}
$1 == current {
        if (current > 1)
                print text;
        text = $0;
        current++;
        next;
}
{
        text = text $0;
}
END {
        if (text != "")
                print text;
}


You will also probably need to add a space (something like:
	text = text " " $0;
It depends on what you need.

br.


On Mon, 2002-08-05 at 19:34, Jean-Christian Imbeault wrote:
> I have a large text file that unfortunately got line-wrapped or something in 
> the transfer and I would like to "undo" the line wrapping ..
> 
> Luckily each line was numbered in the original file so it should make my 
> task easier but
> I've been trying for the last hour to come up with a sed script to concat 
> the lines together but can't seem to get it quite right.
> 
> I have a file that contains lines like this:
> 
> 1 some
> text with
> C/R's
> in annoying places
> 2 more text
> with CRs
> 3 text text text
> 4 text text
> 
> I'd like to concat the lines that don't have leading numbers in to one long 
> line like this:
> 
> 
> 1 sometext with C/R's in annoying places
> 2 more text with CRs
> 3 text text text
> 4 text text
> 
> Can someone suggest a sed (or perl if it is better suited to this) script to 
> concat the lines?
> 
> Thanks!
> 
> Jc
> 
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
> 
> 
> *************************************************
> TLUG server is hosted by Global Online Japan
> http://home.gol.com/index_e.html
> *************************************************
> 
> =================================================
> To unsubscribe from this mailing list, 
> please see instructions at
> http://www.tlug.jp/list.html
> =================================================
> 
-- 
Two witches watched two watches.
Which witch watched which watch?

Attachment: signature.asc
Description: This is a digitally signed message part


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links