Cleanup

Delete empty lines

Remove blank and whitespace-only lines.

What this template solves

Use this template to clean text files, notes, exports, or config snippets by removing empty lines and whitespace-only rows in one pass.

Open the workspace with this template preloaded, then refine it for your own file and text pattern.

Sample input

line one

line two
   
line three

Prompt to start from

Delete empty lines in the text

Expected command

sed '/^\s*$/d'

Tags

cleanupblank-lineswhitespace

Best for

  • Clean copied notes before committing them to a repo.
  • Normalize whitespace in exported lists or generated text files.
  • Remove visual gaps from config or log fragments before further parsing.

How to use this template

  1. 1Check whether the file contains truly blank lines, whitespace-only lines, or both.
  2. 2Copy the sed pattern that deletes empty rows.
  3. 3Run it on a sample or backup first, then apply the file-edit variant for your platform.

Template FAQ

How do I delete empty lines and whitespace-only lines with sed?

A common command is `sed '/^\s*$/d'`, which removes blank rows as well as lines made only of spaces or tabs. This template packages that exact workflow into a reusable landing page with sample input and file-edit guidance.

Will deleting empty lines change non-empty content?

No. This pattern targets only lines that contain no visible characters. It is useful for cleaning exports, notes, logs, and config fragments without touching the real text on populated lines.

Related templates

Explore nearby sed workflows that target similar replace, cleanup, filtering, or rewrite tasks.

Delete empty lines Sed Template | AskSed