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