Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ tr(1) — DG/UX 5.4R3.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed(1)

sh(1)



tr(1)                          DG/UX 5.4R3.00                          tr(1)


NAME
       tr - translate characters

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

DESCRIPTION
       Tr copies the standard input to the standard output, substituting or
       deleting selected characters.  Input characters found in string1 are
       mapped into the corresponding characters of string2.  You can use any
       combination of these options:

       -c      Complements the set of characters in string1 with the
               universe of characters whose ASCII codes are 001 through 377
               octal.

       -d      Deletes all input characters in string1.

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

       The following abbreviation conventions introduce ranges of characters
       or repeated characters into the strings:

       [a-z]   Stands for the string of characters whose ASCII codes run
               from character a to character z, inclusive.

       [a*n]   Stands for 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 is taken to be huge; this facility is
               useful for padding string2.

       Use the escape character \ as in the shell to remove special meaning
       from any character in a string.  In addition, \ followed by one, two,
       or three octal digits stands for the character whose ASCII code is
       given by those digits.

   International Features
       tr can process characters from supplementary code sets.  Characters
       specified are searched for and translated in character units, not
       bytes.

       The semantics of the "[x-y]" notation takes after the range
       specification of the regular expression syntax.

EXAMPLES
       $ cat infile
       aaaabbbccccccc
       $ tr -s "[a-z]" "[A-Z]" <infile > outfile
       $ cat outfile
       ABC
       $

       This example causes all lower case letters in the infile to be



Licensed material--property of copyright holder(s)                         1




tr(1)                          DG/UX 5.4R3.00                          tr(1)


       converted to capital letters in the outfile.  The -s switch causes
       repeated output characters to be "squeezed".

       $ cat infile2
       Mary Wadsmith 23 11/10
       Tim Simon 28 1/15
       Karen Adams 24 3/9
       $ tr -d "[0-9]/" <infile2 >outfile2
       Mary Wadsmith
       Tim Simon
       Karen Adams
       $

       This example causes all numeric values and slashes to be deleted from
       infile1.  All other values are left alone.  The output goes to
       outfile1.

       $ cat infile3
       Jim Wang - employee number 32465
       Grant Stanley - employee number 98757
       Cindy Eddy - employee number 76578
       Mark Hoopes - employee number 78657
       $ tr -cs "[0-9]" "[\012*]" <infile3 >outfile3
       $ cat outfile3
       32465
       98757
       76578
       78657
       $

       This example causes all values in the infile that are not in string1,
       [0-9], to be converted to newlines ( 12 is the ascii value for
       newline).  All of the newlines are "squeezed", and all values that
       are in string1 are left alone (because of the -c option).

       The following example 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 strings are quoted to protect the special
       characters from interpretation by the shell; 012 is the ASCII code
       for new-line.

       tr -cs "[A-Z][a-z]" "[\012*]" <file1 >file2

CAUTION
       When octal notation with the backslash (\) escape character is used,
       a backslash is placed before each byte of characters from
       supplementary code set.

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

BUGS
       Will not handle ASCII NUL in string1 or string2; always deletes NUL
       from input.



Licensed material--property of copyright holder(s)                         2


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