in reply to Re^2: Two line match
in thread Two line match

use -0 to read whole file at once:

cat foo.txt | perl -p0 -e 's/-----\n\n-----/------/g'

Replies are listed 'Best First'.
Re^4: Two line match
by jrosenfeld (Initiate) on Mar 10, 2008 at 16:47 UTC
    Thank you for the suggestion, but it only takes two lines and converts it into 1. I would like a one-liner to convert any number of lines of:

    ------

    into one line of it. Jeff

      Understood.

      perl -p0 -e 's/-----\n(\n|-----\n)*-----\n/-----\n/g' file.txt