Research V4 development
[unix-history] / man / man1 / tr.1
CommitLineData
48b67403
DM
1.th TR I 9/24/73
2.sh NAME
3tr \*- transliterate
4.sh SYNOPSIS
5.bd tr
6[
7.bd \*-cds
8] [ string1 [ string2 ] ]
9.sh DESCRIPTION
10.it Tr
11copies the standard input to the standard output with
12substitution or deletion of selected characters.
13Input characters found in
14.it string1
15are mapped into the corresponding characters of
16.it string2.
17If
18.it string2
19is short, it is padded with corresponding characters from
20.it string1.
21Any combination of the options
22.bd \*-cds
23may be used.
24.bd \*-c
25complements the set of characters in
26.it string1
27with respect to the universe of characters
28whose ascii codes are 001 through 377 octal.
29.bd \*-d
30deletes all input characters not in
31.it string1.
32.bd \*-s
33squeezes all strings of repeated output characters that are
34in
35.it string2
36to single characters.
37.s3
38The following abbreviation conventions may be used
39to introduce ranges of characters or repeated characters into
40the strings:
41.s3
42\fB[\fIa\*|\fB\*-\fIb\fB\*|]\fR
43stands for the string of characters whose ascii codes run
44from character
45.it a
46to character
47.it b.
48.s3
49\fB[\fIa\fB\*|*\fIn\fB\*|]\fR,
50where
51.it n
52is an integer or empty, stands for \fIn\fR-fold
53repetition of character
54.it a.
55.it n
56is taken to be octal or decimal according as its
57first digit is or is not zero.
58A zero or missing
59.it n
60is taken to be huge;
61this facility is useful for padding
62.it string2.
63.s3
64The escape character `\\' may be used as in
65.it sh
66to remove special meaning from any character in a string.
67In addition,
68`\\' followed by 1, 2 or 3 octal digits stands for the
69character whose ascii code is given by those digits.
70.s3
71The following example creates a list of all
72the words in `file1' one per line in `file2',
73where a word is taken to be a maximal string of alphabetics.
74The strings are quoted
75to protect the special characters from interpretation by the Shell;
76012 is the ascii code for newline.
77.s3
78.ti +8
79tr \*-cs "[A\*-Z][a\*-z]" "[\\012*]" <file1 >file2
80.sh "SEE ALSO"
81sh(I), ed(I), ascii(VII)
82.sh BUGS
83Won't handle ascii NUL.
84.br
85Also, Kernighan's Lemma can really bite you;
86try looking for strings which have \\ and * in them.