tr

Replaces specified characters

tr [options] string1 [string2]

The tr utility reads standard input and, for each input character, maps it to an alternate character, deletes the character, or leaves the character alone. The utility writes the result to standard output.

Arguments

The tr utility is typically used with two arguments, string1 and string2. The position of each character in the two strings is important; tr replaces each character from string1 with the corresponding character in string2.

With one argument, string1, and the --delete option, tr deletes the characters specified in string1. The option --squeeze-repeats replaces multiple sequential occurrences of characters in string1 with single occurrences (for example, abbc becomes ...

Get A Practical Guide to Red Hat® Linux® 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.