Remove multiple newlines from a file

Written by  on April 29, 2015 

===========================
Warning 20150507: Just noticed, that the sed-expression also filters identical “not empty” lines from you file! This is not what I wanted. So if you have code with array-initialisations which use the same lines or multiple consecutive calls of the same function, then be careful and check the result of the following command with diff!

Hint 20150508: take a look at this code-snippet. Just copy&paste&compile&run.
===========================

Task to achieve is: remove the superfluous double or triple empty lines between functions. One empty line as separator is acceptable. Two are annoying ..
Workflow is: filter the original source-file and put it into a new file. Remove the old one and replace it.

Maybe I should put it into a shellscript which parses the given directory recursively and applies this to all *., *cpp, *.hpp ..

Category : BashC++

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.