in reply to Re: how to use matching operator on newlines
in thread how to use matching operator on newlines

I don't think that accomplishes the goal. Your solution removes all the blank lines, not just the double-spacing (unlike the other solutions). For example, yours converts a\n\n\n\nb\n\n to a\nb\n rather than a\n\nb\n.

Replies are listed 'Best First'.
Re^3:how to use matching operator on newlines
by BrowserUk (Patriarch) on Jan 03, 2007 at 21:51 UTC

    I don't think that accomplishes the goal.

    It depends upon which of the stated goals you focus on. The op's description started with

    I have a unix-formatted double spaced file, so each line of text is followed by 2 linefeeds,...

    And if that is an accurate statement of the problem, my one-liner will work.

    If it's not accurate, or omits significant details, then it won't and a slightly more sophisticated one-liner is required:

    perl -e"BEGIN{$/=qq[\n\n]}" -ne"chop;print" junk.txt

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.