Delete and Squeeze Characters With tr
Strip CRLF, collapse spaces or translate characters in a stream.
Run tr -d '\r' < windows.txt > unix.txt to remove carriage returns.
01Command
Command
$ tr -d '\r' < windows.txt > unix.txt02What 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
!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
- tr.1.en.html manual page (Debian bookworm)Evidence: Documents tr -d deletion and -s squeeze operations on character streams.
Last verified: 2026-10-13 · Category: Developer