|
|
coherent
tr Command tr
Translate characters
ttrr [-ccddss] _s_t_r_i_n_g_1 [_s_t_r_i_n_g_2]
tr reads characters from the standard input, possibly translates
each to another value or deletes it, and writes to standard out-
put.
Each specified string may contain literal characters of the form
a or \b (where b is non-numeric), octal representations of the
form \ooo (where o is an octal digit), and character ranges of
the form X-Y. tr rewrites each string with the appropriate con-
versions and range expansions.
If an input character is in string1, tr outputs the corresponding
character of string2. If string2 is shorter than string1, the
result is the last character in string2.
The following flags control how ttrr translates characters:
-cc Replace string1 by the set of characters not in string1.
-dd Delete characters in string1 rather than translating them.
-ss The ``squeeze'' option: map a sequence of the same character
from string1 to one output character.
***** Example *****
The following example prints all sequences of four or more spaces
or printing characters from infile:
tr -cs ' -~' '\12' <infile | grep ....
Here string1 is the range from <ssppaaccee> to `~', which includes all
printing characters. Because this example uses the flags -cs, tr
maps sequences of nonprinting characters to newline (octal 12).
***** See Also *****
ASCII, commands, ctype, sed
COHERENT Lexicon Page 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.