4.5 Translate string (tr) |
You can translate (replace) some part of data from the standard input with given string.
Replace string 1 with string 2. The source data comes from the standard input.
They are replaced by each character. The following example, they are replaced such as a to A, b to B, and c to C.
Practice: Translation the contents of file /etc/rc |
$ cat -n /etc/rc | tr abc ABC | head
1 #! /Bin/BAsh
2 #
3 # rC This file is responsiBle for stArting/stopping
4 # serviCes when the runlevel ChAnges.
5 #
6 # OriginAl Author:
7 # Miquel vAn SmoorenBurg,
8 #
9
10 set -m
|
I replaced A with A, B with B, and C with C, and outputted only the first 10 lines. The -n option of cat adds the line number to the beginning of the output.
Also, it is the effect of the head command that only 10 lines were output.