Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)

tr(1) OSS Shell and Utilities Reference Manual
NAME
tr - Translates characters
SYNOPSIS
tr [-Acs] string1 string2
tr -s [-Ac] string1
tr -d [-Ac] string1
tr -ds [-Ac] string1 string2
The tr command copies characters from the standard input to the standard output with sub-
stitution or deletion of selected characters.
FLAGS
-A Translates on a byte-by-byte basis. When you specify this ag, tr does not support
extended characters.
-c Complements (inverts) the set of characters in string1, which is the set of all characters
in the current character set, as dened by the current setting of LC_CTYPE, except for
those actually specied in the string1 argument. These characters are placed in the
array in ascending collation sequence, as dened by the current setting of
LC_COLLATE.
-d Deletes all occurrences of input characters or collating elements found in the array
specied in string1.
If -c and -d are both specied, all characters except those specied by string1 are
deleted. The contents of string2 are ignored, unless -s is also specied. Note, how-
ever, that the same string cannot be used for both the -d and the -s ags; when both
ags are specied, both string1 (used for deletion) and string2 (used for squeezing) are
required.
If -d is not specied, each input character or collating element found in the array
specied by string1 is replaced by the character or collating element in the same rela-
tive position in the array specied by string2.
-s Replaces any character specied in string1 that occurs as a string of two or more
repeating characters as a single instance of the character in string2.
If the string2 contains a character class, the arguments array contains all of the charac-
ters in that character class. For example:
tr -s [:space:]
In a case conversion, however, the string2 array contains only those characters dened
as the second characters in each of the toupper or tolower character pairs, as appropri-
ate. For example:
tr -s [:upper:]’’[:lower:]
DESCRIPTION
Input characters from string1 are replaced with the corresponding characters in string2. If neces-
sary, string1 and string2 can be quoted to avoid pattern matching by the shell.
The following abbreviations can be used to introduce ranges of ASCII characters or repeated
characters:
a-z Stands for a string of characters whose ASCII codes run from character a to character
z, inclusive. No multicharacter collating elements will be included in this range.
918 Hewlett-Packard Company 527188-007