SysIII/usr/src/man/man1/tr.1
.TH TR 1
.SH NAME
tr \- translate characters
.SH SYNOPSIS
.B tr
[
.B \-cds
] [ string1 [ string2 ] ]
.SH DESCRIPTION
.I Tr\^
copies the standard input to the standard output with
substitution or deletion of selected characters.
Input characters found in
.I string1\^
are mapped into the corresponding characters of
.IR string2 .
Any combination of the options
.B \-cds
may be used:
.TP 8
.B \-c
Complements the set of characters in
.I string1\^
with respect to the universe of characters
whose
.SM ASCII
codes are 001 through 377 octal.
.TP
.B \-d
Deletes all input characters in
.IR string1 .
.TP
.B \-s
Squeezes all strings of repeated output characters that are
in
.I string2\^
to single characters.
.PP
The following abbreviation conventions may be used
to introduce ranges of characters or repeated characters into
the strings:
.TP 8
.B [\^a\-z\^]
Stands for the string of characters whose
.SM ASCII
codes run
from character
.B a
to character
.BR z ,
inclusive.
.TP
.BI [\^a\(** n ]
Stands for \fIn\fP repetitions of \fBa\fP.
If the first digit of
.I n\^
is
.BR 0 ,
.I n\^
is considered octal; otherwise,
.I n\^
is taken to be decimal.
A zero or missing
.I n\^
is taken to be huge;
this facility is useful for padding
.IR string2 .
.PP
The escape character
.B \e
may be used as in
the shell
to remove special meaning from any character in a string.
In addition,
.B \e
followed by 1, 2, or 3 octal digits stands for the
character whose
.SM ASCII
code is given by those digits.
.PP
The following example creates a list of all
the words in \fIfile1\fP one per line in \fIfile2\fP,
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
.SM ASCII
code for newline.
.PP
.ti +8
tr \|\-cs \|"[A\-Z][a\-z]" \|"[\\012\(**]" \|<file1 \|>file2
.SH "SEE ALSO"
ed(1), sh(1), ascii(7).
.SH BUGS
Won't handle
.SM ASCII
.SM
.B NUL
in
.I string1\^
or
.IR string2 ;
always deletes
.SM
.B NUL
from input.