Delete and Squeeze Characters With tr

Strip CRLF, collapse spaces or translate characters in a stream.

LinuxtextscriptingcliLow risk
Run tr -d '\r' < windows.txt > unix.txt to remove carriage returns.

01Command

Command
$ tr -d '\r' < windows.txt > unix.txt

02What it does

tr maps or deletes single characters across a stream, so converting line endings, collapsing repeated separators or stripping control characters is one command. It is widely used to clean data between tools, a pipeline task with no GUI equivalent.

03Risk

RiskLow risk
RequirementsPreinstalled on Linux (GNU coreutils)
!Warning: tr operates on bytes and is not UTF-8 aware for multibyte characters in all cases; verify on non-ASCII data.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: Developer

06Related solutions