MPE/iX Shell and Utilities Reference Manual, Vol 2
tr(1) MPE/iX Shell and Utilities tr(1)
NAME
tr — translation filter
SYNOPSIS
tr [–cs] string1 string2
tr –s [–c] string1
tr –d [–c] string1
tr –ds [–c] string1 string2
DESCRIPTION
tr copies data read from the standard input to the standard output, substituting or deleting
characters as specified by the options and string1 and string2. string1 and string2 are consid-
ered to be sets of characters. In its simplest form, tr translates each character in string1 into
the character at the corresponding position in string2.
Options
tr accepts the following options:
–c complements the set of characters specified by string1. This means that tr constructs
a new set of characters, consisting of all the characters not found in string1 and uses
this new set in place of string1.
–d deletes input characters found in string1 from the output. This string is in ascending
order.
–s tr checks for sequences of a string1 character repeated several consecutive times.
When this happens, tr replaces the sequence of repeated characters with one occur-
rence of the corresponding character from string2;ifstring2 is not specified, the se-
quence is replaced with one occurrence of the repeated character itself. For example,
tr -s abc xyz
translates the input string aaaabccccb into the output string of xyzy.
If you specify both the –d and –s options, you must specify both string1 and string2.
In this case, string1 contains the characters to be deleted while string2 contains char-
acters which are to have multiple consecutive appearances replaced with one appear-
ance of the character itself. For example,
tr -ds a b
translates the input string abbbaaacbb into the output string bcb.
The actions of the –s option take place after all other deletions and translations.
Commands and Utilities 1-611