aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cli/tr.md
blob: a8789240ab5642d85d83a6383f673a7f04bc5c83 (plain) (blame)
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
# tr(1)

```
tr [opt] str1 [str2]
    -d      delete characters in str1
    -s      squeeze repeating sequence of characters in str1
```

## Examples

### To lower
```sh
echo MoOsE | tr '[:upper:]' '[:lower:]'
# output: moose
```

### Replace characters
```sh
echo moose | tr 'o' '-'
# output: m--se

echo moose | tr 'os' '-'
# output: m---e
```

### Remove specific characters
```sh
echo moose | tr -d 'o'
# output: mse

echo moose | tr -d 'os'
# output: me
```

### Squeeze character sequences
```sh
echo moooooossse | tr -s 'os'
# output: mose
```