Mailing List Archive


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

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



>>>>> "JI" == Jean-Christian Imbeault <jean_christian@example.com> writes:

    JI> I have a file that contains lines like this:

    JI> 1 some
    JI> text with
    JI> C/R's
    JI> in annoying places
    JI> 2 more text
    JI> with CRs
    JI> 3 text text text
    JI> 4 text text

    JI> I'd like to concat the lines that don't have leading numbers
    JI> in to one long line like this:

    JI> 1 sometext with C/R's in annoying places
    JI> 2 more text with CRs
    JI> 3 text text text
    JI> 4 text text

    JI> Can someone suggest a sed (or perl if it is better suited to
    JI> this) script to concat the lines?

If your file is named crs.txt, do

$ perl -pe 'BEGIN{$/=""} s/\n(?=\D)/ /g' < crs.txt

Well I wanted something like

perl -pe 's/\n(\D)/ $1/sg' < crs.txt
or
perl -pe 's/\n(?=\D)/ /sg' < crs.txt

but they don't work. Any ideas why?

Viktor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links