blob: ca5001fb5fdad787d66ef4cf8192f90699faafe6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<?xml version="1.0" encoding="UTF-8"?>
<guide self="tools-reference/tr/">
<chapter>
<title>tr — Character Translation</title>
<body>
<p>
The <c>tr</c> command can be used to translate, squeeze and delete character
sequences. See <c>man tr</c> and
<uri link="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/tr.html">
IEEE Std 1003.1-2017-tr</uri> for the full specification.
</p>
<note>
<c>tr</c>, unlike most other utilities, only reads from standard input
and only writes to standard output. Therefore, you will have to use
<c>tr [options] < input > output</c>.
</note>
<p>
<c>tr</c> operates in a number of modes, depending upon the invocation:
</p>
<dl>
<dt>
Deleting characters
</dt>
<dd>
To delete all occurrences of certain characters, use <c>tr -d asdf</c>.
</dd>
<dt>
Deleting repeated characters
</dt>
<dd>
To replace repeated characters with a single character ('squeeze'), use
<c>tr -s asdf</c>.
</dd>
<dt>
Transliterating characters
</dt>
<dd>
To replace all 'a' characters with '1', all 'b' with '2' and all 'c' with
'3', use <c>tr abc 123</c>.
</dd>
</dl>
<p>
Certain special forms are allowed for the arguments. <c>a-z</c> expands to all
characters from 'a' to 'z', <c>\t</c> represents a tab and so on. See the
documentation for a full list.
</p>
</body>
</chapter>
</guide>
|