O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required