===========================
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.
1 |
$ cat source.cpp | sed '$!N; /^\(.*\)\n\1$/!P; D' > source_tmp.cpp && rm source.cpp && mv source_tmp.cpp source.cpp |
Maybe I should put it into a shellscript which parses the given directory recursively and applies this to all *., *cpp, *.hpp ..
Leave a Reply
You must be logged in to post a comment.