[Chicago-talk] Replacing consecutive newlines with a single newline

Vijay Kumar vjcang at gmail.com
Thu Sep 25 18:04:10 PDT 2008

  I need to do it as part of unix command line invocation.
  I thought I knew it but after trying for almost one hour I am still
unable to get it right.
  Your ideas much appreciated.

       perl -pe 's/(\n)+/\1/g' inputfile
       perl -pe 's/(\n)+/\1/sg' inputfile
   are not working.

   I see the following reduces consecutive 'x' s to a single 'x'
   perl -pe 's/(x)+/\1/g' inputfile

   Not sure why it is not doing it for newline character. May be it is
very stupid mistake.


More information about the Chicago-talk mailing list