Squeeze consecutive newline characters.

Section: tr Translation and Character Operations

Collapse repeated blank lines

bash
bash
tr -s '
' < file.txt
Explanation

Can help normalize output before diffing or exporting.

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 tr Translation and Character Operations
Join lines into one line
Replace newlines with spaces.
OpenIn sheetbashsame section
Convert lowercase to uppercase
Translate characters from lower to upper case.
OpenIn sheetbashsame section
Convert uppercase to lowercase
Translate text to lowercase.
OpenIn sheetbashsame section
Delete characters
Remove all digits from a stream.
OpenIn sheetbashsame section
Extract comma-delimited fields
Print the first and third fields from a CSV-like file.
Sort lines alphabetically
Default lexicographic sort.