Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed(1)

expand(1)

sed(1)

ascii(7)

TR(1)                                BSD                                 TR(1)



NAME
     tr - translate characters

SYNOPSIS
     tr [ -cds ] [ string1 [ string2 ] ]

DESCRIPTION
     tr copies the standard input to the standard output with substitution or
     deletion of selected characters.  Input characters found in string1 are
     mapped into the corresponding characters of string2.  When string2 is
     short, it is padded to the length of string1 by duplicating its last
     character.

     In either string, the notation a-b means a range of characters from a to
     b in increasing ASCII order.  A backslash (\) followed by 1, 2, or 3
     octal digits stands for the character whose ASCII code is given by those
     digits.  A backslash followed by any other character stands for that
     character.

OPTIONS
     -c        Complement the set of characters in string1 with respect to the
               universe of characters whose ASCII codes are 01 through 0377
               octal.

     -d        Delete all input characters in string1.

     -s        Squeeze all strings of repeated output characters in string2 to
               single characters.

EXAMPLE
     The example below creates a list of all the words in file1, one per line
     in file2, where a word is taken to be a maximal string of alphabetics.
     The second string is quoted to protect the backslash from the shell.  The
     012 is the ASCII code for newline.

          tr -cs A-Za-z '\012' <file1 >file2

BUGS
     tr cannot handle ASCII NUL in string1 or string2.  It always deletes the
     NUL from input.

SEE ALSO
     ed(1), expand(1), sed(1), ascii(7)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026