Translates characters (BSD version).
trbsd [ -c ] [ -d ] [ -s ] [ -A ] [ String1 [ String2 ] ]
The trbsd command deletes or substitutes characters from standard input and then writes the result to standard output. The trbsd command is the BSD version of the tr command. The trbsd command performs three kinds of operations, depending on the character strings specified by the parameters and flags specified. The default value for either the String1 or String2 parameter is a null string.
If both the String1 and String2 parameters are specified and the -d flag is not specified, the trbsd command replaces each character from standard input that is specified by the String1 parameter with the character in the same position in the String2 parameter.
If the String1 parameter specifies a character more than once, the character is translated into the character in the String2 parameter that corresponds to the last occurrence of the character in the String1 parameter.
If the -d flag is specified, the trbsd command deletes each character from standard input that is specified by the String1 parameter.
If the -s flag is specified, the trbsd command deletes from standard input all but the first character in a sequence of two or more repetitions of any character specified by the String2 parameter.
Both the String1 and String2 parameters must be specified when both the -d and -s flags are specified.
Note: The trbsd command deletes all null characters from standard input before it begins processing.
The strings contained in String1 and String2 parameters can be expressed using the following conventions:
If the strings specified by the String1 and String2 parameters are not the same length, the trbsd command pads the shorter string to equal the length of the longer string. Padding is accomplished by duplicating the last character in the shorter string as many times as necessary.
trbsd '{}' '()' < textfile > newfile
This translates each { (left brace) to ( (left parenthesis) and each } (right brace) to ) (right parenthesis). All other characters remain unchanged.
trbsd '+\-/*' '\-+*/' < textfile > newfile
The minus sign must be entered with a backslash escape character.
trbsd 'a-z' 'A-Z' < textfile > newfile
trbsd -cs 'a-zA-Z' '\012' < textfile > newfile
This translates each sequence of characters other than lowercase letters and uppercase letters into a single newline character. The octal value 012 is the code for the newline character.
trbsd -s '\012' < textfile > newfile
/usr/bin/trbsd | Contains the trbsd command. |
/usr/ucb/tr | Contains a symbolic link to the trbsd command. |
National Language Support Overview in AIX 5L Version 5.2 National Language Support Guide and Reference.