mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-11-17 12:08:43 +00:00
310 lines
8.8 KiB
Groff
310 lines
8.8 KiB
Groff
.\" Copyright (c) 1991, 1993
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
.\"
|
|
.\" This code is derived from software contributed to Berkeley by
|
|
.\" the Institute of Electrical and Electronics Engineers, Inc.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
.\" must display the following acknowledgement:
|
|
.\" This product includes software developed by the University of
|
|
.\" California, Berkeley and its contributors.
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
.\" may be used to endorse or promote products derived from this software
|
|
.\" without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.\" @(#)tr.1 8.1 (Berkeley) 6/6/93
|
|
.\" $Id: tr.1,v 1.3 1997/10/03 04:13:24 gdr Exp $
|
|
.\"
|
|
.TH TR 1 "August 1997" "GNO" "Commands and Applications"
|
|
.SH NAME
|
|
.BR tr
|
|
\- translate characters
|
|
.SH SYNOPSIS
|
|
.BR tr " [" -cs ]
|
|
.IR "string1" " " "string2"
|
|
.PP
|
|
.BR tr " [" -c "] " -d
|
|
.I string1
|
|
.PP
|
|
.BR tr " [" -c "] " -s
|
|
.I string1
|
|
.PP
|
|
.BR tr " [" -c "] " -ds
|
|
.IR "string1" " " "string2"
|
|
.SH DESCRIPTION
|
|
The
|
|
.BR tr
|
|
utility copies the standard input to the standard output with substitution
|
|
or deletion of selected characters.
|
|
.LP
|
|
The following options are available:
|
|
.RS
|
|
.IP \fB-c\fR
|
|
Complements the set of characters in
|
|
.IR string1 ,
|
|
that is ``-c ab'' includes every character except for ``a'' and ``b''.
|
|
.IP \fB-d\fR
|
|
The
|
|
.B -d
|
|
option causes characters to be deleted from the input.
|
|
.IP \fB-s\fR
|
|
The
|
|
.B -s
|
|
option squeezes multiple occurrences of the characters listed in the last
|
|
operand (either
|
|
.IR string1
|
|
or
|
|
.IR string2 )
|
|
in the input into a single instance of the character.
|
|
This occurs after all deletion and translation is completed.
|
|
.RE
|
|
.PP
|
|
In the first synopsis form, the characters in
|
|
.IR string1
|
|
are translated into the characters in
|
|
.IR string2
|
|
where the first character in
|
|
.IR string1
|
|
is translated into the first character in
|
|
.IR string2
|
|
and so on.
|
|
If
|
|
.IR string1
|
|
is longer than
|
|
.IR string2 ,
|
|
the last character found in
|
|
.IR string2
|
|
is duplicated until
|
|
.IR string1
|
|
is exhausted.
|
|
.PP
|
|
In the second synopsis form, the characters in
|
|
.IR string1
|
|
are deleted from the input.
|
|
.PP
|
|
In the third synopsis form, the characters in
|
|
.IR string1
|
|
are compressed as described for the
|
|
.B -s
|
|
option.
|
|
.PP
|
|
In the fourth synopsis form, the characters in
|
|
.IR string1
|
|
are deleted from the input, and the characters in
|
|
.IR string2
|
|
are compressed as described for the
|
|
.B -s
|
|
option.
|
|
.PP
|
|
The following conventions can be used in
|
|
.IR string1
|
|
and
|
|
.IR string2
|
|
to specify sets of characters:
|
|
.RS
|
|
.IP character
|
|
Any character not described by one of the following conventions
|
|
represents itself.
|
|
.IP \fB\\\\\fRoctal
|
|
A backslash followed by 1, 2 or 3 octal digits represents a character
|
|
with that encoded value.
|
|
To follow an octal sequence with a digit as a character, left zero-pad
|
|
the octal sequence to the full 3 octal digits.
|
|
.IP \fB\\\\\fRcharacter
|
|
A backslash followed by certain special characters maps to special
|
|
values.
|
|
.sp
|
|
.RS
|
|
\fB\\a\fR <alert character>
|
|
.br
|
|
\fB\\b\fR <backspace>
|
|
.br
|
|
\fB\\f\fR <form-feed>
|
|
.br
|
|
\fB\\n\fR <newline>
|
|
.br
|
|
\fB\\r\fR <carriage return>
|
|
.br
|
|
\fB\\t\fR <tab>
|
|
.br
|
|
\fB\\v\fR <vertical tab>
|
|
.RE
|
|
.sp
|
|
A backslash followed by any other character maps to that character.
|
|
.IP \fIc1\fR-\fIc2\fR
|
|
Represents the range of characters between the range endpoints, inclusively.
|
|
.IP \fB[:\fRclass\fB:]\fR
|
|
Represents all characters belonging to the defined character class.
|
|
Class names are:
|
|
.sp
|
|
.RS
|
|
\fBalnum\fR <alphanumeric characters>
|
|
.br
|
|
\fBalpha\fR <alphabetic characters>
|
|
.br
|
|
\fBblank\fR <\\t, `` ''>
|
|
.br
|
|
\fBcntrl\fR <control characters>
|
|
.br
|
|
\fBdigit\fR <numeric characters>
|
|
.br
|
|
\fBgraph\fR <graphic characters>
|
|
.br
|
|
\fBlower\fR <lower-case alphabetic characters>
|
|
.br
|
|
\fBprint\fR <printable characters>
|
|
.br
|
|
\fBpunct\fR <punctuation characters>
|
|
.br
|
|
\fBspace\fR <\\t, \\n, \\v, \\f, \\r, `` ''>
|
|
.br
|
|
\fBupper\fR <upper-case characters>
|
|
.br
|
|
\fBxdigit\fR <hexadecimal characters>
|
|
.br
|
|
.RE
|
|
.PP
|
|
With the exception of the ``upper'' and ``lower'' classes, characters
|
|
in the classes are in unspecified order.
|
|
In the ``upper'' and ``lower'' classes, characters are entered in
|
|
ascending order.
|
|
.PP
|
|
For specific information as to which ASCII characters are included
|
|
in these classes, see
|
|
.IR ctype (3)
|
|
and related manual pages.
|
|
.IP \fB[=\fRequiv\fB=]\fR
|
|
Represents all characters or collating (sorting) elements belonging to
|
|
the same equivalence class as
|
|
.IR equiv .
|
|
If
|
|
there is a secondary ordering within the equivalence class, the characters
|
|
are ordered in ascending sequence.
|
|
Otherwise, they are ordered after their encoded values.
|
|
An example of an equivalence class might be ``c'' and ``ch'' in Spanish;
|
|
English has no equivalence classes.
|
|
Note: because the functions in
|
|
.IR locale.h
|
|
are not implemented for the Apple IIGS, English is the only supported
|
|
language.
|
|
.IP \fB[\fR#\fB*\fRn\fB]\fR
|
|
Represents
|
|
.IR n
|
|
repeated occurrences of the character represented by
|
|
.IR # .
|
|
This
|
|
expression is only valid when it occurs in
|
|
.IR string2 .
|
|
If
|
|
.IR n
|
|
is omitted or is zero, it is be interpreted as large enough to extend
|
|
.IR string2
|
|
sequence to the length of
|
|
.IR string1 .
|
|
If
|
|
.IR n
|
|
has a leading zero, it is interpreted as an octal value, otherwise,
|
|
it's interpreted as a decimal value.
|
|
.RE
|
|
.PP
|
|
The
|
|
.BR tr
|
|
utility exits 0 on success, and >0 if an error occurs.
|
|
.SH EXAMPLES
|
|
The following examples are shown as given to the shell:
|
|
.PP
|
|
Create a list of the words in file1, one per line, where a word is taken to
|
|
be a maximal string of letters.
|
|
.HP
|
|
tr -cs '[:alpha:]' '\\n' < file1
|
|
.PP
|
|
Translate the contents of file1 to upper-case.
|
|
.HP
|
|
tr '[:lower:]' '[:upper:]' < file1
|
|
.PP
|
|
Strip out non-printable characters from file1.
|
|
.HP
|
|
tr -cd '[:print:]' < file1
|
|
.SH COMPATIBILITY
|
|
System V has historically implemented character ranges using the syntax
|
|
``[c-c]'' instead of the ``c-c'' used by historic BSD implementations and
|
|
standardized by POSIX.
|
|
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
|
|
``tr [a-z] [A-Z]'' will work as it will map the ``['' character in
|
|
.IR string1
|
|
to the ``['' character in
|
|
.IR string2.
|
|
However, if the shell script is deleting or squeezing characters as in
|
|
the command ``tr -d [a-z]'', the characters ``['' and ``]'' will be
|
|
included in the deletion or compression list which would not have happened
|
|
under an historic System V implementation.
|
|
Additionally, any scripts that depended on the sequence ``a-z'' to
|
|
represent the three characters ``a'', ``-'' and ``z'' will have to be
|
|
rewritten as ``a\\-z''.
|
|
.PP
|
|
The
|
|
.BR tr
|
|
utility has historically not permitted the manipulation of NUL bytes in
|
|
its input and, additionally, stripped NUL's from its input stream.
|
|
This implementation has removed this behavior as a bug.
|
|
.PP
|
|
The
|
|
.BR tr
|
|
utility has historically been extremely forgiving of syntax errors,
|
|
for example, the
|
|
.B -c
|
|
and
|
|
.B -s
|
|
options were ignored unless two strings were specified.
|
|
This implementation will not permit illegal syntax.
|
|
.SH STANDARDS
|
|
The
|
|
.BR tr
|
|
utility is expected to be
|
|
.B POSIX.2
|
|
compatible.
|
|
It should be noted that the feature wherein the last character of
|
|
.IR string2
|
|
is duplicated if
|
|
.IR string2
|
|
has less characters than
|
|
.IR string1
|
|
is permitted by POSIX but is not required.
|
|
Shell scripts attempting to be portable to other POSIX systems should use
|
|
the ``[#*]'' convention instead of relying on this behavior.
|
|
.SH VERSION
|
|
This manual page documents
|
|
.BR tr
|
|
version 2.0.
|
|
.SH ATTRIBUTIONS
|
|
This command was ported from FreeBSD source code
|
|
for distribution with GNO/ME 2.0.6.
|
|
.SH HISTORY
|
|
Version 1.0 (November 3, 1994) of
|
|
.BR tr
|
|
was written by
|
|
Thomas. R. Wyant III
|
|
and distributed as a
|
|
separate package compatible with GNO and ORCA.
|