Remove empty lines from output.

Section: sed Line Deletion and Printing

Delete blank lines

bash
bash
sed '/^$/d' file.txt
Explanation

A common cleanup step before diffing or processing text.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing sed Line Deletion and Printing
Delete comment lines
Skip lines that begin with `#`.
OpenIn sheetbashsame section
Delete a line range
Remove lines 5 through 10.
OpenIn sheetbashsame section
Print only matching lines
Use sed as a pattern filter.
OpenIn sheetbashsame section
Print a line range only
Show lines 5 through 10.
OpenIn sheetbashsame section
Replace first occurrence per line
Substitute one match in each line.
OpenIn sheetbash1 tag match
Replace all occurrences per line
Substitute every match on each line.
OpenIn sheetbash1 tag match