Unix |
Unix v6 |
|
![]() |
tr(1) |
![]() |
tr transliterate [ ] [ string1 [ string2 ] ] copies the
standard input to the standard output with substitution or
deletion of selected characters. Input characters found in
are mapped into the corresponding characters of Any
combination of the options may be used. complements the set
of characters in with respect to the universe of characters
whose ascii codes are 001 through 377 octal. deletes all
input characters in squeezes all strings of repeated output
characters that are in to single characters. The following
abbreviation conventions may be used to introduce ranges of
characters or repeated characters into the strings:
[ab] stands for the string of
characters whose ascii codes run from character to character
[a*n], where is an
integer or empty, stands for n-fold repetition of
character is taken to be octal or decimal according as its
first digit is or is not zero. A zero or missing is taken to
be huge; this facility is useful for padding The escape
character ‘\’ may be used as in to remove
special meaning from any character in a string. In addition,
‘\’ followed by 1, 2 or 3 octal digits stands
for the character whose ascii code is given by those digits.
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
newline.
tr cs "[AZ][az]" "[\012*]" <file1
>file2 sh (I), ed (I), ascii (V) Won’t handle ascii
NUL in or always deletes NUL from input.
![]() |
tr(1) | ![]() |