version 1.5, 2000/03/05 00:28:55 |
version 1.6, 2000/03/11 21:40:05 |
|
|
.Ar string1 string2 |
.Ar string1 string2 |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
The |
The |
.Nm tr |
.Nm |
utility copies the standard input to the standard output with substitution |
utility copies the standard input to the standard output with substitution |
or deletion of selected characters. |
or deletion of selected characters. |
.Pp |
.Pp |
|
|
.It \echaracter |
.It \echaracter |
A backslash followed by certain special characters maps to special |
A backslash followed by certain special characters maps to special |
values. |
values. |
.sp |
.Pp |
.Bl -column |
.Bl -column |
.It \ea <alert character> |
.It \ea <alert character> |
.It \eb <backspace> |
.It \eb <backspace> |
|
|
.It \et <tab> |
.It \et <tab> |
.It \ev <vertical tab> |
.It \ev <vertical tab> |
.El |
.El |
.sp |
.Pp |
A backslash followed by any other character maps to that character. |
A backslash followed by any other character maps to that character. |
.It c-c |
.It c-c |
Represents the range of characters between the range endpoints, inclusively. |
Represents the range of characters between the range endpoints, inclusively. |
.It [:class:] |
.It [:class:] |
Represents all characters belonging to the defined character class. |
Represents all characters belonging to the defined character class. |
Class names are: |
Class names are: |
.sp |
.Pp |
.Bl -column |
.Bl -column |
.It alnum <alphanumeric characters> |
.It alnum <alphanumeric characters> |
.It alpha <alphabetic characters> |
.It alpha <alphabetic characters> |
|
|
.El |
.El |
.Pp |
.Pp |
The |
The |
.Nm tr |
.Nm |
utility exits 0 on success or >0 if an error occurred. |
utility exits 0 on success or >0 if an error occurred. |
.Sh EXAMPLES |
.Sh EXAMPLES |
The following examples are shown as given to the shell: |
The following examples are shown as given to the shell: |
.sp |
.Pp |
Create a list of the words in file1, one per line, where a word is taken to |
Create a list of the words in file1, one per line, where a word is taken to |
be a maximal string of letters. |
be a maximal string of letters. |
.sp |
.Pp |
.D1 Li "tr -cs \*q[:alpha:]\*q \*q\en\*q < file1" |
.D1 Li "tr -cs \*q[:alpha:]\*q \*q\en\*q < file1" |
.sp |
.Pp |
Translate the contents of file1 to upper-case. |
Translate the contents of file1 to upper-case. |
.sp |
.Pp |
.D1 Li "tr \*q[:lower:]\*q \*q[:upper:]\*q < file1" |
.D1 Li "tr \*q[:lower:]\*q \*q[:upper:]\*q < file1" |
.sp |
.Pp |
Strip out non-printable characters from file1. |
Strip out non-printable characters from file1. |
.sp |
.Pp |
.D1 Li "tr -cd \*q[:print:]\*q < file1" |
.D1 Li "tr -cd \*q[:print:]\*q < file1" |
|
.Sh SEE ALSO |
|
.Xr sed 1 |
.Sh COMPATIBILITY |
.Sh COMPATIBILITY |
System V has historically implemented character ranges using the syntax |
System V has historically implemented character ranges using the syntax |
.Dq [c-c] |
.Dq [c-c] |
|
|
used by historic BSD implementations and |
used by historic BSD implementations and |
standardized by POSIX. |
standardized by POSIX. |
System V shell scripts should work under this implementation as long as |
System V shell scripts should work under this implementation as long as |
the range is intended to map in another range, i.e. the command |
the range is intended to map in another range, i.e., the command |
.Dq tr\ [a-z]\ [A-Z] |
.Dq tr\ [a-z]\ [A-Z] |
will work as it will map the |
will work as it will map the |
.Dq [ |
.Dq [ |
|
|
.Dq a\e-z . |
.Dq a\e-z . |
.Pp |
.Pp |
The |
The |
.Nm tr |
.Nm |
utility has historically not permitted the manipulation of NUL bytes in |
utility has historically not permitted the manipulation of NUL bytes in |
its input and, additionally, has stripped NUL's from its input stream. |
its input and, additionally, has stripped NUL's from its input stream. |
This implementation has removed this behavior as a bug. |
This implementation has removed this behavior as a bug. |
.Pp |
.Pp |
The |
The |
.Nm tr |
.Nm |
utility has historically been extremely forgiving of syntax errors: |
utility has historically been extremely forgiving of syntax errors: |
for example, the |
for example, the |
.Fl c |
.Fl c |
|
|
This implementation will not permit illegal syntax. |
This implementation will not permit illegal syntax. |
.Sh STANDARDS |
.Sh STANDARDS |
The |
The |
.Nm tr |
.Nm |
utility is expected to be |
utility is expected to be |
.St -p1003.2 |
.St -p1003.2 |
compatible. |
compatible. |