Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ tr(1) — A/UX 2.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dd(1)

ed(1)

sh(1)

ascii(5)




tr(1) tr(1)
NAME tr - translate characters SYNOPSIS tr [-c] [-d] [-s] [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 correspond- ing characters of string2. For the substitution to work correctly, string2 must have at least as many characters as string1; excess characters in either string are ignored by tr. Similarly, when using the -c option, string1 must have at least as many characters as the complement of string1. Any combination of the flag options -cds may be used. -c Complements the set of characters in string1 with respect to 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 into single characters. The following abbreviation conventions may be used to intro- duce 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. The escape character \ may be used, as in the shell, to re- move special meaning from any character in a string. In ad- dition, \ followed by 1, 2, or 3 octal digits stands for the character whose ASCII code is given by those digits. EXAMPLES tr -cs "[A-Z][a-z]" "[\012*]" <file1 >file2 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 al- phabetics. (The strings are quoted to protect the special characters from interpretation by the shell; 012 is the ASCII code for newline.) This was accomplished via the fol- lowing translations: tr substitutes the newline character April, 1990 1



tr(1) tr(1)
for all the alphabetics in file1, reconstitutes the alpha- betics with the -c flag option, squeezes the newlines to one per occurrence with the -s flag option, and directs the out- put to file2. FILES /usr/bin/tr SEE ALSO dd(1), ed(1), sh(1), ascii(5), ``Other Text Processing Tools'' in A/UX Text Processing Tools. BUGS Won't handle ASCII NUL in string1 or string2; always deletes NUL from input. 2 April, 1990

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