gtpo1m6cOperations

ZFILE tr-Translate or Delete Characters

Use this command to substitute or delete characters from the standard input (stdin) stream and pass the results to the standard output (stdout) stream. The results are displayed on the screen, but the input file is not changed.

Requirements and Restrictions

Format




-c
complements the set of characters specified in string1. The ZFILE tr command constructs a case-sensitive string of characters not contained in string1 and uses that constructed string as the translation control string.

-s
replaces characters in string1 with the corresponding positional characters in string2 while eliminating consecutive duplicate characters. If string2 is not specified, the consecutive duplicate characters are replaced with a single occurrence of itself. The actions of the -s parameter take place after all other deletions and translations.

-d
deletes all instances of characters found in string1.

string1
is the translation control string, which consists of characters to be converted into an array and replaced or deleted in translation.

string2
is the translation control string, which is used to replace characters specified in string1. Unless the -s parameter is specified, characters in string1 are replaced one-for-one by characters in string2.

Additional Information

Examples

In the following example, file tempfile contains string aaaabccccb. The -s parameter indicates that characters specified in string1 (abc) are replaced by corresponding, positional characters in string2 (xyz) while duplicated characters are eliminated:

+--------------------------------------------------------------------------------+
|User:   ZFILE tr -s abc xyz < tempfile                                          |
|                                                                                |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM tr -s abc xyz < tempfile       |
|        xyzy                                                                    |
|        END OF DISPLAY                                                          |
+--------------------------------------------------------------------------------+

In the following example, file tempfile contains the following single string:

one		two		three

Each word is separated by two tab characters (\t). Note that in the display, the words one, two, and three have not been separated by the new-line (\n) character. The actions of the -s parameter take place after all other deletions and translations.

+--------------------------------------------------------------------------------+
|User:   ZFILE tr -ds "\t" "\n" < tempfile                                       |
|                                                                                |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM tr -ds "\t" "\n" < tempfile    |
|        onetwothree                                                             |
|        END OF DISPLAY                                                          |
+--------------------------------------------------------------------------------+

In the following example, all lowercase characters from a to s are replaced by their uppercase equivalent. File tempfile contains the following:

one
two
three

Each word is separated with a new-line character (\n).

+--------------------------------------------------------------------------------+
|User:   ZFILE tr a-s A-S < tempfile                                             |
|                                                                                |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM tr a-s A-S < tempfile          |
|        ONE                                                                     |
|        twO                                                                     |
|        tHREE                                                                   |
|        END OF DISPLAY                                                          |
+--------------------------------------------------------------------------------+

Related Information

See Information Technology--Portable Operating System Interface for Computer Environments (POSIX) for more information about the POSIX standards.