12.1. About tr
Tr is a utility that lets you translate characters by substitution or deletion from standard input. Tr is used mainly for stripping off control characters from files or doing character case conversions. When you use tr you generally pass it two strings: string1 is what you are searching for and string2 is what you want done with the translation. When tr is initially invoked, the characters in string1 are mapped across into the characters of string2; the conversion will then begin.
In this chapter we will cover:
converting lower to upper case;
stripping files of control characters; and
deleting blank lines.
The formats of the tr command with its most used options are:
tr -c -d -s ["string1_to_translate_from"] ["string2_to_translate_to"] input_file ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access