tr

Translate or delete single characters in a stream

About

A tiny filter that maps one set of characters to another, or deletes them. It works character by character, not on words or lines. That suits case changes and cleanup, and normalising whitespace before further processing.

Install it

Included with Termux

Run this inside Termux. If the package is already present, pkg will say so and do nothing.

Commands worth knowing

6 of the invocations you will actually reach for. Tap the copy button to put one on your clipboard.

tr a-z A-Z Map every lowercase letter to its uppercase counterpart.
tr -d "0-9" Delete all digits from the input.
tr -s " " Squeeze runs of spaces down to a single space.
tr -c "a-zA-Z0-9" " " Replace every character that is not a letter or digit with a space.
tr -d "[:punct:]" Delete all punctuation characters from the input.
tr A-Z N-ZA-M Rotate the alphabet, each letter shifting thirteen places.

Worked example

Run tr a-z A-Z and this is what you should see.

termux
$ tr a-z A-Z
HELLO FROM TERMUX
THE QUICK BROWN FOX
GOOD MORNING

Developed by

GNU Project .