Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • That's right. And yes it is possible that the pattern can occur multiple times in a file. After looking into the answer from @maulinglawns it's probably better to use another language because grep is only applied to the first found line Commented Nov 14, 2016 at 14:31
  • Note, if you want to limit blank lines in your file you can alway run a substitution after-the-fact. In the Raku programming language (fomerly Perl_6), running the one-liner raku -e 'put S/\n**3..*/\n\n/ given slurp();' converts any two-or-more consecutive blank lines to a single blank line. raku.org Commented Jul 10, 2023 at 12:52