


      TR(1)                       (UNIX 5.0)                      TR(1)



      NAME
           tr - translate characters

      SYNTAX
           tr [ -cds ] [ string1 [ string2 ] ]

      DESCRIPTION
           Tr deletes specified input characters, or does an in-order
           mapping of the characters in string1 to the characters in
           string2.

           -c      Complement.  string1 will be equivalent to every
                   ASCII character, in the ASCII code range 1 to 255 (1
                   to 377 octal) except the ones specified.

           -d      Deletes all input characters in string1.  IGNORES
                   string2.

           -s      Squeezes repititions of output characters that are
                   in string2 to single characters and IGNORES string1,
                   or repetitions of characters found in string1 if
                   there is no string2.

           The following abbreviation conventions may be used to
           introduce ranges of characters or repeated characters into
           the strings:

           [a-z]   Represents a range of characters as ordered in the
                   ASCII table.

           [a*n]   Represents n repetitions of a.  If the first digit
                   of n is 0, n is considered octal; otherwise, n is
                   taken to be decimal.  A zero or missing n represents
                   an indefinite number.  When the first string
                   specifies a range of characters, and you don't know
                   how many it would match but want to replace all of
                   them with a certain other character, use * or *0 in
                   string2 to represent "as many as necessary."

           Use \ to remove any special meaning from a character in a
           string.  To represent ASCII characters by their octal codes,
           use \ followed by 1, 2, or 3 octal digits for the character.


      EXAMPLES
           To change all b's to k's:  tr b k < myfile

           To change all b's to k's and all p's to e's: tr bp ke <
           myfile

           To get rid of all b's and squeeze the f's: tr -ds b f




      Page 1                                          (73 A2 02MT REV1)






      TR(1)                       (UNIX 5.0)                      TR(1)



           To print only the punctuation from a text: tr -d "[A-Z][a-
           z]" < text

           The strings are quoted to protect the special characters
           from interpretation by the shell.

           To create a list of alphabetic-only words (one per line)
           derived from text:

                   tr -cs "[A-Z][a-z]" "[\012*]" < text

           (012 is the octal ASCII code for newline.) In English:
           Translate everything but alphabetics into as many newline
           characters as may be required, but squeeze (-s) the
           excessive repetitions of newline characters into just one
           newline.

           Leave out the -s and excessive newlines appear because they
           are not squeezed.  Leave out the -c and alphabetic strings
           (words) are turned into newlines, and only the punctuation
           will be output.

      SEE ALSO
           ed(1), sh(1), ascii(5).

      BUGS
           Won't handle ASCII NUL in either string, and always deletes
           NUL from input.



























      Page 2                                          (73 A2 02MT REV1)



