home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
tr100.zip
/
TR.DOC
next >
Wrap
Text File
|
1993-04-12
|
7KB
|
169 lines
--------------------------------------------------------------------------
This program is distributed as shareware. If you like and use this
program, please send $5 via check or banknote to :
Ms. Shuyi Chen
206 West 99th Street #6A
NYC NY 10025
If you have comments or find bugs, please write to the address above
or send an electronic mail message to fernand@cs.nyu.edu, with a
Subject line indicating the message is for SHUYI CHEN.
--------------------------------------------------------------------------
NAME: TR - translate characters (and a little more).
SYNOPSIS: TR, run without arguments prints :
tr (Version 1.0) USAGE : tr [options] FROMSTRING TOSTRING
-d[c] "..." Deletes characters in [complement of] ...
-s[c] "..." Squeezes characters in [complement of] ...
-S Squeeze All
-(l/u/t) (Lower/Raise/Toggle) Case
-w List Words : Whitespace -> Squeezed Newline
-W "..." List Words : "..." -> Squeezed Newline
-ff Flatten : Flat (Deletes Newline)
-f Flatten : (Newline -> Squeezed Space)
-fr "..." Flatten : Join with (rotating) ... characters
-F# "s1" ... "s#" Flatten : Join with # (rotating) strings
-p Pad output if shorter (default Delete)
-b Binary Processing (Default Off)
-DU, Dos-To-Unix (Deletes Return and Control-Z)
-UD, -UDZ Unix-To-Dos (\n -> \r\n), Control-Z Termination
-e[c] "..." ",,," Transforms characters in [complement of] "..." to ",,,"
a-z == Inclusive Range e.g. a-z, Z-A, l-z etc
\ Octal Escape. e.g. \012 == Newline
\\ == \, \n == Newline, \- == -, \w == Whitespace == " \t\n"
\r == Return, \t == Tab
DESCRIPTION
TR is a pure filter. i.e it copies standard in to standard
out with substitution or deletion of selected characters. The
arguments FROMSTRING and TOSTRING are considered sets of
characters. Any input character found in FROMSTRING is mapped
into the character in the corresponding position within
TOSTRING. Normally, FROMSTRING and TOSTRING need not be
enclosed in quotes.
NOTATION:
a-e
(for example) denotes a range of characters from a to e in
increasing or decreasing ASCII order. How about when you want
to use "-" as a regular character? In this case, you use the
\ character to escape the range interpretation of "-", i.e.
"a\-z" will indicate the characters "a", "-" and "z", not the
range a to z.
In the same way, "\" is used to escape the special meaning of
"\" itself. The "\" character may also be used to indicate
nonprinting characters. In fact, if you know the octal
representation of the character, it may be represented as a
"\" followed by 3 octal digits that denote the character whose
ASCII code is given by those digits. For example "\012" is a
Newline. Several short forms are defined for the more common
nonprinting characters. Specifically:
\\ == \
\- == -
\t == Tab
\n == Newline
\r == Return
\w == Whitespace == " \t\n"
OPTIONS
"-p" Used to change the default course of action of the program
when TOSTRING is shorter than FROMSTRING. The default action
is to ignore the excess characters appearing in FROMSTRING,
but the "-p" option instead results in padding out TOSTRING to
the length of FROMSTRING, using the last character in TOSTRING
as the padding character. For instance, if you typed :
tr abcde ABC
the default action would be to ignore 'd' and 'e' in the
argument "abcde", but the "-p" option causes the following
interpretation:
tr abcde ABCCC
"-d" If specified, the next argument should be a string, all of
whose characters are removed by TR.
"-dc" As above, except characters in the complement of the string
argument are deleted.
"-S" Squeezes all characters. i.e. multiple (consecutive)
occurrences of any character are replaced with a single
occurrence.
"-s" Applies the afore-mentioned squeezing to characters in the
string following this option.
"-sc" As above, except characters in the complement of the string
argument are squeezed.
"-l" Lowers case
"-u" Raises case
"-t" Toggles case
"-w" Replaces whitespace with a squeezed newline. This may be used
to make a list of "words".
"-W" Replaces whitespace as above but redefines the meaning of
"whitespace" to the set of characters comprising the string
following the option.
"-f" Performs the inverse of the "-w" option, by deleting newlines
and replacing them with a single space. This can be used to
get a list of words on a single line from a list of words that
are one to a line.
"-ff" Like the "-f" option but it does not add a separating space
when it joins lines.
"-fr" Provides flexibility in specifying the character that is used
to join lines. The characters in the string following the
option are used sequentially. If the string runs out and
there are still lines to be joined, then the string is reused.
"-F" Provides still greater flexibility, in that instead of using
characters, one may specify strings to be used to join lines.
When using this option, you must tell the program how many
strings you are providing. For example, "-F2" says 2 strings
will follow, and ofcourse you must provide 2 strings after the option.
"-DU" (Dos-To-Unix) option converts the input from DOS text to Unix
text. i.e. Carriage Returns are deleted and so are Control Z
characters.
"-UD" (Unix-To-Dos) does the reverse, replacing Newlines with
Carriage-Return Newline pairs.
"-UDZ" (Unix-To-Dos-with-Control-Z) terminates the output with a
Control-Z character, besides replacing Newlines with
Carriage-Return Newline pairs.
"-e" Should be followed by 2 strings which are interpreted just
like the aforementioned FROMSTRING and TOSTRING.
"-ec" As above, except the characters in the complement of FROMSTRING
are translated.
"-b" Toggles binary processing. The program default is to delete
carriage returns from the input and to emit a carriage return
prior to every newline emitted. Use of the "-b" option turns
this off; carriage returns are treated like any other
character. This option is useful if a binary file is being
processed.
NOTE: This program is not a direct superset of UNIX tr. In
particular repetitions are not supported, options must be
specified separately and octal representations require all 3
characters. On the plus side, a few common tasks are directly
specifiable, lines may be joined more flexibly and multiple
options may be used.