

tr                           Command                           tr




Translate characters

ttrr [-ccddss] _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 ttrr translates characters:

-cc Replace string1 by the set of characters not in string1.

-dd Delete characters in string1 rather than translating them.

-ss 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 <ssppaaccee> 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


