💾 Archived View for mirrors.apple2.org.za › archive › apple.cabi.net › Utilities › TR.SHK.DOC.txt captured on 2024-02-05 at 11:46:01.
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
tr V1.0 tr.c implements the Unix command "tr". It is compatible with the System V "tr", except that the first character list is required. Also, "C" escape sequences \a, \b, \f, \n, \r, \t, and \v are recognized, as well as hexadecimal character codes (encoded as \xnn). Characters may still be specified by their octal values. The basic syntax is tr [options] instring [outstring] with input being from stdin and output to stdout. Unix input and output redirection (ie: <infile, >outfile, or both) is used to handle input from or output to a file. The basic functionality of "tr" (which is executed without any options present) is to replace every character in the input file which appears in the input string with the corresponding character in the output string. If the strings are different length the longer one is truncated. The options are those in the "man" entry for "tr" (with the exception of -f, which is added); that is: -c = complement the input string; that is, the input string consists of all characters in the character set which are NOT in the input string, in order of increacing unsigned character code. -f = compress out the first occurrance of characters in the output string; that is, if character 'c' appears in the output string, then any string of n 'c's in the input file will become n-1 'c's in the output file. -d = delete characters in the input string from the input file; if this option is present the input and output strings need not be the same length. -s = compress out multiple occurrances of characters in the output string. -? = display short help and copyright information; this will also be done on a syntax error. The input and output strings are specified using either literal characters, escape sequences, ranges (specified as [a-b], representing the characters from 'a' to 'b' inclusive), or repeats (specified as [a*n], meaning n occurrances of character 'a'). In repeats the 'n' may be omitted or specified as zero, signifying an indefinitely large number. Examples: tr [A-Z] [a-z] translates uppercase characters to lowercase. tr \r \n translates carriage returns to newlines. tr -cs [a-z][A-Z] \n produces as output all the words in the input, at one word per line. Note that depending on what shell you are using, you may need to quote the strings to prevent the shell from converting them to upper-case. Copyright Thomas. R. Wyant III, Richmond, VA, 1992-1994. This program is freeware. It can be copied and distributed freely as long as all copyright and warranty information is included, but not sold for a profit. The Apple IIgs version of this program contains material from the ORCA/C Run-Time Libraries, Copyright 1987-1989 by Byte Works, Inc. Used with permission. "Apple" and "IIgs" are trademarks of Apple Computer, Inc. WARRANTY INFORMATION: The author uses "tr" frequently, and has made a reasonable effort to be sure that it is bug-free. However, he also makes regular backups to guard against unexpected bugs (both his own and others'), as well as cockpit error. So should you. THOMAS R. WYANT, III MAKES NO WARRANTIES EITHER EXPRESSED OR IMPLIED REGARDING THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE, AND SHALL HAVE NO LIABILITY TO THE USER OF THIS SOFTWARE FOR ANY LOSS OR OTHER DAMAGE CAUSED OR ALLEGED TO BE CAUSED EITHER DIRECTLY OR INDIRECTLY BY THE USE OF THIS SOFTWARE.