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

Vijay Kumar vjcang at gmail.com
Fri Sep 26 22:02:01 PDT 2008


Sorry for not being clear about the problem. The intention was to
replace consecutive 2+ multiple blank lines with 2 blank lines.

Today I checked-in some code like below that formats Oracle's spool output.

    perl -0777 -pi -e 's/^SQL>//mg; s/\n{2,}/\n\n/g' inputfile
    cat inputfile | mailx ....

and obviously giving credit to Andy in the comments and explaining about 0777.

Thanks
VIJAY


On 26/09/2008, Steven Lembark <lembark at wrkhors.com> wrote:
>
>>> This can also be written as
>>
>>      perl -n -e 'print if /./'
>>
>> or - fore! [1]:
>>      perl -p -e 'next if /^$/'
>>
>> drat, no shorter.
>
> Can't win 'em all :-)
>
> --
> Steven Lembark                                            85-09 90th St.
> Workhorse Computing                                 Woodhaven, NY, 11421
> lembark at wrkhors.com                                      +1 888 359 3508
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>


-- 

VIJAY


More information about the Chicago-talk mailing list