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