new version, from scratch; pass through NUL's like everything else
[unix-history] / usr / src / usr.bin / tr / tr.1
CommitLineData
6f64075a 1.\" @(#)tr.1 6.1 (Berkeley) %G%
5fc0f5dd 2.\"
6f64075a 3.TH TR 1 ""
5fc0f5dd
KM
4.AT 3
5.SH NAME
6tr \- translate characters
7.SH SYNOPSIS
8.B tr
9[
10.B \-cds
11] [ string1 [ string2 ] ]
12.SH DESCRIPTION
13.I Tr
14copies the standard input to the standard output with
15substitution or deletion of selected characters.
16Input characters found in
17.I string1
18are mapped into the corresponding characters of
19.IR string2 .
20When
21.I string2
22is short it is padded to the length of
23.I string1
24by duplicating its last character.
25Any combination of the options
26.B \-cds
27may be used:
28.B \-c
29complements the set of characters in
30.I string1
31with respect to the universe of characters
32whose ASCII codes are 01 through 0377 octal;
33.B \-d
34deletes all input characters in
35.I string1;
36.B \-s
37squeezes all strings of repeated output characters that are
38in
39.I string2
40to single characters.
41.PP
42In either string the notation
43.IB a \- b
44means a range of characters from
45.I a
46to
47.I b
48in increasing ASCII order.
49The character
50`\e' followed by 1, 2 or 3 octal digits stands for the
51character whose ASCII code is given by those digits.
52A `\e' followed by any other character stands
53for that character.
54.PP
55The following example creates a list of all
56the words in `file1' one per line in `file2',
57where a word is taken to be a maximal string of alphabetics.
58The second string is quoted
59to protect `\e' from the Shell.
60012 is the ASCII code for newline.
61.IP
62tr \-cs A\-Za\-z \'\e012\' <file1 >file2
63.SH "SEE ALSO"
64ed(1), ascii(7), expand(1)
65.SH BUGS
66Won't handle ASCII NUL in
67.I string1
68or
69.I string2;
70always deletes NUL from input.