[Chicago-talk] Replacing consecutive newlines with a single newline
Randal L. Schwartz
merlyn at stonehenge.com
Thu Sep 25 18:31:20 PDT 2008
>>>>> "Vijay" == Vijay Kumar <vjcang at gmail.com> writes:
Vijay> Not sure why it is not doing it for newline character. May be it is
Vijay> very stupid mistake.
Because $_ contains a single newline character, always.
Perhaps you want to simply delete any entirely blank lines..
perl -ne 'print if /\S/'
Or even simpler:
(That's grep, and a single dot.)
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
More information about the Chicago-talk