version 1.3, 1998/10/30 00:24:40 |
version 1.4, 1999/04/30 06:24:25 |
|
|
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Fl c |
.It Fl c |
Complements the set of characters in |
Complements the set of characters in |
.Ar string1 , |
.Ar string1 ; |
that is ``-c ab'' includes every character except for ``a'' and ``b''. |
for instance, |
|
.Dq -c\ ab |
|
includes every character except for |
|
.Dq a |
|
and |
|
.Dq b . |
.It Fl d |
.It Fl d |
The |
The |
.Fl d |
.Fl d |
|
|
Any character not described by one of the following conventions |
Any character not described by one of the following conventions |
represents itself. |
represents itself. |
.It \eoctal |
.It \eoctal |
A backslash followed by 1, 2 or 3 octal digits represents a character |
A backslash followed by 1, 2, or 3 octal digits represents a character |
with that encoded value. |
with that encoded value. |
To follow an octal sequence with a digit as a character, left zero-pad |
To follow an octal sequence with a digit as a character, left zero-pad |
the octal sequence to the full 3 octal digits. |
the octal sequence to the full 3 octal digits. |
|
|
\." and vice-versa) is specified in the same relative position in |
\." and vice-versa) is specified in the same relative position in |
\." .Ar string1 . |
\." .Ar string1 . |
\." .Pp |
\." .Pp |
With the exception of the ``upper'' and ``lower'' classes, characters |
With the exception of the |
|
.Dq upper |
|
and |
|
.Dq lower |
|
classes, characters |
in the classes are in unspecified order. |
in the classes are in unspecified order. |
In the ``upper'' and ``lower'' classes, characters are entered in |
In the |
|
.Dq upper |
|
and |
|
.Dq lower |
|
classes, characters are entered in |
ascending order. |
ascending order. |
.Pp |
.Pp |
For specific information as to which ASCII characters are included |
For specific information as to which ASCII characters are included |
|
|
If |
If |
there is a secondary ordering within the equivalence class, the characters |
there is a secondary ordering within the equivalence class, the characters |
are ordered in ascending sequence. |
are ordered in ascending sequence. |
Otherwise, they are ordered after their encoded values. |
Otherwise, they are ordered after their encoded values. |
An example of an equivalence class might be ``c'' and ``ch'' in Spanish; |
An example of an equivalence class might be |
|
.Dq c |
|
and |
|
.Dq ch |
|
in Spanish; |
English has no equivalence classes. |
English has no equivalence classes. |
.It [#*n] |
.It [#*n] |
Represents |
Represents |
|
|
.Ar string1 . |
.Ar string1 . |
If |
If |
.Ar n |
.Ar n |
has a leading zero, it is interpreted as an octal value, otherwise, |
has a leading zero, it is interpreted as an octal value; otherwise, |
it's interpreted as a decimal value. |
it's interpreted as a decimal value. |
.El |
.El |
.Pp |
.Pp |
|
|
.D1 Li "tr -cd \*q[:print:]\*q < file1" |
.D1 Li "tr -cd \*q[:print:]\*q < file1" |
.Sh COMPATIBILITY |
.Sh COMPATIBILITY |
System V has historically implemented character ranges using the syntax |
System V has historically implemented character ranges using the syntax |
``[c-c]'' instead of the ``c-c'' used by historic BSD implementations and |
.Dq [c-c] |
|
instead of the |
|
.Dq c-c |
|
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 |
``tr [a-z] [A-Z]'' will work as it will map the ``['' character in |
.Dq tr\ [a-z]\ [A-Z] |
|
will work as it will map the |
|
.Dq [ |
|
character in |
.Ar string1 |
.Ar string1 |
to the ``['' character in |
to the |
|
.Dq [ |
|
character in |
.Ar string2 . |
.Ar string2 . |
However, if the shell script is deleting or squeezing characters as in |
However, if the shell script is deleting or squeezing characters as in |
the command ``tr -d [a-z]'', the characters ``['' and ``]'' will be |
the command |
included in the deletion or compression list which would not have happened |
.Dq tr\ -d\ [a-z] , |
|
the characters |
|
.Dq [ |
|
and |
|
.Dq \] |
|
will be |
|
included in the deletion or compression list, which would not have happened |
under an historic System V implementation. |
under an historic System V implementation. |
Additionally, any scripts that depended on the sequence ``a-z'' to |
Additionally, any scripts that depended on the sequence |
represent the three characters ``a'', ``-'' and ``z'' will have to be |
.Dq a-z |
rewritten as ``a\e-z''. |
to represent the three characters |
|
.Dq a , |
|
.Dq - , |
|
and |
|
.Dq z |
|
will have to be rewritten as |
|
.Dq a\e-z . |
.Pp |
.Pp |
The |
The |
.Nm tr |
.Nm tr |
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, 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 tr |
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 |
and |
and |
|
|
.Ar string1 |
.Ar string1 |
is permitted by POSIX but is not required. |
is permitted by POSIX but is not required. |
Shell scripts attempting to be portable to other POSIX systems should use |
Shell scripts attempting to be portable to other POSIX systems should use |
the ``[#*]'' convention instead of relying on this behavior. |
the |
|
.Dq [#*] |
|
convention instead of relying on this behavior. |