'\"macro stdmacro
.if n .pH g1.tr @(#)tr	40.4 of 1/8/90
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} tr 1 "Directory and File Management Utilities" "\&"
.if \nX=1 .ds x} tr 1 "Directory and File Management Utilities"
.if \nX=2 .ds x} tr 1 "" "\&"
.if \nX=3 .ds x} tr "" "" "\&"
.TH \*(x}
.SH NAME
\f4tr\f1 \- translate characters
.SH SYNOPSIS
\f4tr\f1
[
\f4\-cds\f1
] [ \f2string1\f1 [ \f2string2\f1 ] ]
.SH DESCRIPTION
\f4tr\fP
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
\f4\-cds\f1
may be used:
.TP 8
\f4\-c\f1
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
\f4\-d\f1
Deletes all input characters in
.IR string1 .
.TP
\f4\-s\f1
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
\f4[\^a\-z\^]\f1
Stands for the string of characters whose
.SM ASCII
codes run
from character
\f4a\f1
to character
\f4z\f1,
inclusive.
.TP
\f4[\^a\(**\f2n\f4]\f1
Stands for \f2n\fP repetitions of \f4a\fP.
If the first digit of
.I n\^
is
\f40\f1,
.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
\f4\e\f1
may be used as in
the shell
to remove special meaning from any character in a string.
In addition,
\f4\e\f1
followed by 1, 2, or 3 octal digits stands for the
character whose
.SM ASCII
code is given by those digits.
.SH EXAMPLE
The following example creates a list of all
the words in \f2file1\fP one per line in \f2file2\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 +6
\f4tr \|\-cs \|"[A\-Z][a\-z]" \|"[\\012\(**]" \|<\f2file1\fP>\|\f2file2\f1
.SH "SEE ALSO"
\f4ed\fP(1), \f4sh\fP(1).
.br
\f4ascii\fP(5) in the \f2System Administrator's Reference Manual\f1.
.SH NOTES
Will not handle
.SM ASCII
.SM
\f4NUL\f1
in
.I string1
or
.IR string2 ;
always deletes
.SM
\f4NUL\f1
from input.
.\"	@(#)tr.1	6.2 of 9/2/83
.Ee
