OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / gnumaniak / original / man1 / tr.1
diff --git a/manual/gnumaniak/original/man1/tr.1 b/manual/gnumaniak/original/man1/tr.1
new file mode 100644 (file)
index 0000000..97ef2ee
--- /dev/null
@@ -0,0 +1,314 @@
+.\" You may copy, distribute and modify under the terms of the LDP General
+.\" Public License as specified in the LICENSE file that comes with the
+.\" gnumaniak distribution
+.\"
+.\" The author kindly requests that no comments regarding the "better"
+.\" suitability or up-to-date notices of any info documentation alternative
+.\" is added without contacting him first.
+.\"
+.\" (C) 2002 Ragnar Hojland Espinosa <ragnar@ragnar-hojland.com>
+.\"
+.\"    GNU tr man page
+.\"    man pages are NOT obsolete!
+.\"    <ragnar@ragnar-hojland.com>
+.TH TR 1 "7 October 2002" "GNU textutils 2.1"
+.SH NAME
+\fBtr\fR \- translate, squeeze, and/or delete characters
+.SH SYNOPSIS
+.B tr
+.RB [ \-cdst\ ]
+.RB [ \-\-complement ]
+.RB [ \-\-delete ]
+.RB [ \-\-squeeze\-repeats ]
+.RB [ \-\-truncate\-set1 ]
+.IR FILE1 " [" FILE2 ]
+
+.BR tr " [" \-\-help "] [" \-\-version ]
+.SH DESCRIPTION
+.B tr
+copies standard input to standard output, performing one of the
+following operations:
+.IP
+\fB\(bu\fR translate, and optionally squeeze repeated characters in the result
+.IP
+\fB\(bu\fR squeeze repeated characters
+.IP
+\fB\(bu\fR delete characters
+.IP
+\fB\(bu\fR delete characters, then squeeze repeated characters from the result
+.PP
+The \fISET1\fR and (if given) \fISET2\fR arguments define ordered sets of
+characters, referred to below as \fISET1\fR and \fISET2\fR.  These sets are
+the characters of the input that \fBtr\fR operates on.  The \fB\-c\fR option
+replaces \fISET1\fR with its complement (all of the characters that are not
+in \fISET1\fR).
+.SH OPTIONS
+.TP
+.B \-c, \-\-complement
+Replace \fISET1\fR with its complement (that is, all the characters that are
+not in \fISET1\fR.
+.TP
+.B \-d, \-\-delete
+Delete any input characters that are in \fISET1\fR, do not translate.
+.TP
+.B \-s, \-\-squeeze\-repeats
+Replace sequence of characters with one; this is done after translating or
+deleting. It replaces each input sequence of a repated character that is in
+\fISET1\fR with a single occurrence of that character.
+.TP
+.B \-t, \-\-truncate\-set1
+Before doing any translations, first truncate \fISET1\fR to length of
+\fISET2\fR.
+.TP
+.B "\-\-help"
+Print a usage message on standard output and exit successfully.
+.TP
+.B "\-\-version"
+Print version information on standard output then exit successfully.
+.SH SPECIFYING SETS
+The format of the \fISET1\fR and \fISET2\fR arguments resembles the format of
+regular expressions; however, they are not regular expressions, only
+lists of characters.  Most characters simply represent themselves in
+these strings, but the strings can contain the shorthands listed below,
+for convenience.  Some of them can be used only in \fISET1\fR or \fISET2\fR,
+as noted below.
+.SS Backslash Escapes
+.RS
+.TP
+.B \ea
+Control\-G
+.TP
+.B \eb
+Control\-H
+.TP
+.B \ef
+Control\-L
+.TP
+.B \en
+Control\-J
+.TP
+.B \er
+Control\-M
+.TP
+.B \et
+Control\-I
+.TP
+.B \ev
+Control\-K
+.TP
+.B \e\fIOOO
+The character with the value given by \fIOOO\fR, which is 1 to 3 octal digits
+.TP
+.B \e\e
+A backslash
+.PP
+.SS Ranges
+The notation `\fIM\fR\-\fIN\fR' expands to all of the characters from 
+\fiM\fR through \fIN\fR, in ascending order.  \fIM\fR should collate before
+\fIN\fR; if it doesn't, an error results.  As an example, `0\-9' is the same as
+`0123456789'.  Although GNU \fBtr\fR does not support the System V
+syntax that uses square brackets to enclose ranges, translations
+specified in that format will still work as long as the brackets
+in \fISTRING1\fR correspond to identical brackets in \fISTRING2\fR.
+.SS Repeated Characters
+The notation `\fB[\fIC\fB*\fIN\fB]\fR' in \fISET2\fR expands to \fIN\fR
+copies of character \fIC\fR.  Thus, `[y*6]' is the same as `yyyyyy'.  The
+notation `[C*]' in \fISTRING2\fR expands to as many copies of C as are
+needed to make \fISET2\fR as long as \fISET1\fR.  If \fIN\fR begins with
+`0', it is interpreted in octal, otherwise in decimal.
+.SS Character Classes
+The notation `\fB[:\fICLASS\fB:]\fR' expands to all of the
+characters in the
+(predefined) class \fICLASS\fR.  The characters expand in no particular
+order, except for the \fBupper\fR and \fBlower\fR classes, which expand in
+ascending order.  When the \fB\-\-delete\fR and \fB\-\-squeeze\-repeats\fR
+options are both given, any character class can be used in \fISET2\fR.
+Otherwise, only the character classes  \fBlower\fR and \fBupper\fR are
+accepted in \fISET2\fR, and then only if the corresponding character class
+(\fBupper\fR and \fBlower\fR, respectively) is specified in the same
+relative position in \fISET1\fR.  Doing this specifies case conversion.  The
+class names are given below; an error results when an invalid class name is
+given. 
+.RS
+.TP
+.B alnum
+Letters and digits
+.TP
+.B alpha
+Letters
+.TP
+.B blank
+Horizontal whitespace
+.TP
+.B cntrl
+Control characters
+.TP
+.B digit
+Digits
+.TP
+.B graph
+Printable characters, not including space
+.TP
+.B lower
+Lowercase letters
+.TP
+.B print
+Printable characters, including space
+.TP
+.B punct
+Punctuation characters
+.TP
+.B space
+Horizontal or vertical whitespace
+.TP
+.B upper
+Uppercase letters
+.TP
+.B xdigit
+Hexadecimal digits
+.PP
+.SS Equivalence Classes
+The syntax `\fB[=\fIC\fB=]\fR' expands to all of the characters that are
+equivalent to \fIC\fR, in no particular order.  Equivalence classes are
+a relatively recent invention intended to support non-English alphabets.
+But there seems to be no standard way to define them or determine their
+contents.  Therefore, they are not fully implemented in GNU \fBtr\fR; each
+character's equivalence class consists only of that character, which is of
+no particular use.
+.SH TRANSLATING
+\fBtr\fR performs translation when \fISET1\fR and \fISET2\fR are both given and
+\fB\-\-delete\fR is not specified.  \fRtr\fN translates each character
+of its input that is in \fISET1\fR to the corresponding character in \fISET2\fR.
+Characters not in \fISET1\fR are passed through unchanged.  When a character
+appears more than once in \fISET1\fR and the corresponding characters in \fISET2\fR
+are not all the same, only the final one is used.  For example, these
+two commands are equivalent:
+.sp
+.RS
+.nf
+tr aaa xyz
+tr a z
+.fi
+.RE
+.sp
+A common use of \fBtr\fR is to convert lowercase characters to
+uppercase.  This can be done in many ways.  Here are three of them:
+.sp
+.RS
+.nf
+tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
+tr a\-z A\-Z
+tr '[:lower:]' '[:upper:]'
+.fi
+.RE
+.sp
+When \fBtr\fR is performing translation, \fISET1\fR and \fISET2\fR typically have
+the same length.  If \fISET1\fR is shorter than \fISET2\fR, the extra characters at
+the end of \fISET2\fR are ignored.
+
+On the other hand, making \fISET1\fR longer than \fISET2\fR is not portable;
+POSIX.2 says that the result is undefined.  In this situation, BSD \fBtr\fR
+pads \fISET2\fR to the length of \fISET1\fR by repeating the last character
+of \fISET2\fR as many times as necessary.  System V \fBtr\fR truncates
+\fBSET1\fR to the length of \fBSET2\fR.
+
+By default, GNU \fBtr\fR handles this case like BSD \fBtr\fR.  When the
+\fB\-\-truncate\-set1\fR option is given, GNU \fBtr\fR handles this case
+like the System V \fBtr\fR instead.  This option is ignored for operations
+other than translation. Acting like System V \fBtr\fR in this case breaks the
+relatively common BSD idiom:
+.sp
+.RS
+.nf
+tr \-cs A\-Za\-z0\-9 '\e012'
+.fi
+.RE
+.sp
+because it converts only zero bytes (the first element in the
+complement of \fISET1\fR), rather than all non-alphanumerics, to newlines.
+.SH SQUEEZING REPEATS AND DELETING
+When given just the \fB\-\-delete\fR option, \fBtr\fR removes any input
+characters that are in \fISET1\fR.
+
+When given just the \fB\-\-squeeze\-repeats\fR option, \fBtr\fR replaces
+each input sequence of a repeated character that is in \fISET1\fR with a
+single occurrence of that character.
+
+When given both \fB\-\-delete\fR and \fB\-\-squeeze\-repeats\fR, \fBtr\fR
+first performs any deletions using \fISET1\fR, then squeezes repeats from any
+remaining characters using \fISET2\fR.
+
+The \fB\-\-squeeze\-repeats\fR option may also be used when translating, in
+which case tr' first performs translation, then squeezes repeats from
+any remaining characters using \fISET2\fR.
+
+Here are some examples to illustrate various combinations of options:
+
+\fB\(bu\fR Remove all zero bytes
+.sp
+.RS
+.nf
+tr \-d '\e000'
+.fi
+.RE
+.sp
+\fB\(bu\fR Put all words on lines by themselves.  This converts all
+non-alphanumeric characters to newlines, then squeezes each string
+of repeated newlines into a single newline
+.sp
+.RS
+.nf
+tr \-cs '[a\-zA\-Z0\-9]' '[\en*]'
+.fi
+.RE
+.sp
+\fB\(bu\fR Convert each sequence of repeated newlines to a single newline
+.sp
+.RS
+.nf
+tr \-s '\en'
+.fi
+.RE
+.sp
+\fB\(bu\fR Find doubled occurrences of words in a document.  For example,
+people often write "the the" with the duplicated words separated by a
+newline.  The bourne shell script below works first by converting each
+sequence of punctuation and blank characters to a single newline.  That puts
+each "word" on a line by itself.  Next it maps all uppercase characters to
+lower case, and finally it runs \fBuniq\fR(1) with the \fB\-d\fR option to
+print out only the words that were adjacent duplicates.
+.sp
+.RS
+.nf
+#!/bin/sh
+cat "$@" \e
+| tr \-s '[:punct:][:blank:]' '\en' \e
+| tr '[:upper:]' '[:lower:]' \e
+| uniq \-d
+.fi
+.RE
+.sp                                                         
+.SH COMPATIBILITY
+Setting the environment variable \fBPOSIXLY_CORRECT\fR turns off the
+following warning and error messages, for strict compliance with
+POSIX.2.  Otherwise, the following diagnostics are issued:
+.IP
+1. When the \fB\-\-delete\fR option is given but \fB\-\-squeeze\-repeats\fR is
+not, and \fISET2\fR is given, GNU \fBtr\fR by default prints a usage message
+and exits, because \fISET2\fR would not be used.  The POSIX specification
+says that \fISET2\fR must be ignored in this case.  Silently ignoring
+arguments is a bad idea.
+.IP
+2. When an ambiguous octal escape is given.  For example, `\400' is
+actually \40' followed by the digit `0', because the value 400
+octal does not fit into a single byte.
+.PP      
+GNU \fBtr\fR does not provide complete BSD or System V compatibility.
+For example, it is impossible to disable interpretation of the POSIX
+constructs `[:alpha:]', `[=c=]', and `[c*10]'.  Also, GNU \fBtr\fR does not
+delete zero bytes automatically, unlike traditional Unix versions,
+which provide no way to preserve zero bytes.        
+.SH NOTES
+Report bugs to bug-textutils@gnu.org.
+.br
+Man page by Ragnar Hojland Espinosa <ragnar@ragnar-hojland.com>