What this template solves
Use this template to normalize text that contains too many consecutive blank lines while still keeping one visual separator between blocks.
Open the workspace with this template preloaded, then refine it for your own file and text pattern.
Sample input
alpha
beta
gammaPrompt to start from
Remove duplicate blank lines but keep a single blank line between sections
Expected command
sed '/^$/N;/^\n$/D'Tags
cleanupblank-linesspacingformatting
Best for
- Clean pasted notes that contain many duplicate blank rows.
- Normalize generated docs or reports with excessive spacing.
- Prepare text for sharing while preserving section separation.
How to use this template
- 1Check whether you want to remove every blank line or only collapse repeated blank lines.
- 2Copy the sed command that removes consecutive duplicate empty rows.
- 3Preview on representative sample text, then run the platform-specific file-edit command if needed.
Template FAQ
How do I remove duplicate blank lines but keep one separator line?
A common sed approach is `sed '/^$/N;/^\n$/D'`, which collapses consecutive empty rows while preserving a single blank line between blocks of text.
What is the difference between delete-empty-lines and remove-duplicate-blank-lines?
Delete-empty-lines removes every blank row, while remove-duplicate-blank-lines preserves one empty separator and only removes repeated duplicates. That makes it better for keeping readable section spacing.
Related templates
Explore nearby sed workflows that target similar replace, cleanup, filtering, or rewrite tasks.