home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / man / cat1 / tr.0 < prev    next >
Text File  |  1993-12-07  |  11KB  |  331 lines

  1.  
  2.  
  3.  
  4. TR(1L)                                                     TR(1L)
  5.  
  6.  
  7. NNAAMMEE
  8.        tr - translate or delete characters
  9.  
  10. SSYYNNOOPPSSIISS
  11.        ttrr   [-cst]  [--complement]  [--squeeze-repeats]  [--trun-
  12.        cate-set1] string1 string2
  13.        ttrr {-s,--squeeze-repeats} [-c] [--complement] string1
  14.        ttrr {-d,--delete} [-c] string1
  15.        ttrr {-d,--delete}  {-s,--squeeze-repeats}  [-c]  [--comple-
  16.        ment] string1 string2
  17.  
  18.        GNU ttrr also accepts the --help and --version options.
  19.  
  20. DDEESSCCRRIIPPTTIIOONN
  21.        This  manual  page  documents  the  GNU version of ttrr..  ttrr
  22.        copies the standard input to the standard output, perform-
  23.        ing one of the following operations:
  24.  
  25.               +o  translate, and optionally squeeze repeated char-
  26.               acters in the result
  27.               +o squeeze repeated characters
  28.               +o delete characters
  29.               +o delete characters, then squeeze repeated  charac-
  30.               ters from the result.
  31.  
  32.        The  _s_t_r_i_n_g_1  and  (if  given)  _s_t_r_i_n_g_2  arguments  define
  33.        ordered sets of characters, referred to below as set1  and
  34.        set2.   These sets are the characters of the input that ttrr
  35.        operates on.  The _-_-_c_o_m_p_l_e_m_e_n_t (_-_c) option  replaces  set1
  36.        with its complement (all of the characters that are not in
  37.        set1).
  38.  
  39.    SSPPEECCIIFFYYIINNGG SSEETTSS OOFF CCHHAARRAACCTTEERRSS
  40.        The format of the _s_t_r_i_n_g_1 and _s_t_r_i_n_g_2 arguments  resembles
  41.        the  format  of regular expressions; however, they are not
  42.        regular expressions, only lists of characters.  Most char-
  43.        acters  simply  represent themselves in these strings, but
  44.        the strings can contain the shorthands listed  below,  for
  45.        convenience.   Some of them can be used only in _s_t_r_i_n_g_1 or
  46.        _s_t_r_i_n_g_2, as noted below.
  47.  
  48.        Backslash escapes.  A backslash followed  by  a  character
  49.        not listed below causes an error message.
  50.  
  51.        \a     Control-G.
  52.  
  53.        \b     Control-H.
  54.  
  55.        \f     Control-L.
  56.  
  57.        \n     Control-J.
  58.  
  59.        \r     Control-M.
  60.  
  61.  
  62.  
  63.  
  64. FSF                     GNU Text Utilities                      1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TR(1L)                                                     TR(1L)
  71.  
  72.  
  73.        \t     Control-I.
  74.  
  75.        \v     Control-K.
  76.  
  77.        \ooo   The character with the value given by _o_o_o, which is
  78.               1 to 3 octal digits.
  79.  
  80.        \\     A backslash.
  81.  
  82.        Ranges.  The notation `_m-_n' expands to all of the  charac-
  83.        ters  from _m through _n, in ascending order.  _m should col-
  84.        late before _n; if it doesn't, an  error  results.   As  an
  85.        example,  `0-9' is the same as `0123456789'.  Although GNU
  86.        ttrr does not support the System V syntax that  uses  square
  87.        brackets to enclose ranges, translations specified in that
  88.        format will still work as long as the brackets in  string1
  89.        correspond to identical brackets in string2.
  90.  
  91.        Repeated  characters.   The  notation  `[_c*_n]'  in _s_t_r_i_n_g_2
  92.        expands to _n copies of character _c.  Thus, `[y*6]' is  the
  93.        same  as `yyyyyy'.  The notation `[_c*]' in _s_t_r_i_n_g_2 expands
  94.        to as many copies of _c as are needed to make set2 as  long
  95.        as  set1.   If  _n  begins  with  a 0, it is interpreted in
  96.        octal, otherwise in decimal.
  97.  
  98.        Character classes.  The notation `[:_c_l_a_s_s_-_n_a_m_e:]'  expands
  99.        to  all  of the characters in the (predefined) class named
  100.        _c_l_a_s_s_-_n_a_m_e.  The characters expand in no particular order,
  101.        except  for  the `upper' and `lower' classes, which expand
  102.        in  ascending  order.   When   the   _-_-_d_e_l_e_t_e   (_-_d)   and
  103.        _-_-_s_q_u_e_e_z_e_-_r_e_p_e_a_t_s (_-_s) options are both given, any charac-
  104.        ter class can be used in  _s_t_r_i_n_g_2.   Otherwise,  only  the
  105.        character  classes  `lower'  and  `upper'  are accepted in
  106.        _s_t_r_i_n_g_2, and then  only  if  the  corresponding  character
  107.        class  (`upper' and `lower', respectively) is specified in
  108.        the same relative position in _s_t_r_i_n_g_1.  Doing this  speci-
  109.        fies case conversion.  The class names are given below; an
  110.        error results when an invalid class name is given.
  111.  
  112.        alnum  Letters and digits.
  113.  
  114.        alpha  Letters.
  115.  
  116.        blank  Horizontal whitespace.
  117.  
  118.        cntrl  Control characters.
  119.  
  120.        digit  Digits.
  121.  
  122.        graph  Printable characters, not including space.
  123.  
  124.        lower  Lowercase letters.
  125.  
  126.        print  Printable characters, including space.
  127.  
  128.  
  129.  
  130. FSF                     GNU Text Utilities                      2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. TR(1L)                                                     TR(1L)
  137.  
  138.  
  139.        punct  Punctuation characters.
  140.  
  141.        space  Horizontal or vertical whitespace.
  142.  
  143.        upper  Uppercase letters.
  144.  
  145.        xdigit Hexadecimal digits.
  146.  
  147.        Equivalence classes.  The syntax `[=_c=]' expands to all of
  148.        the  characters that are equivalent to _c, in no particular
  149.        order.   Equivalence  classes  are  a   recent   invention
  150.        intended  to  support  non-English  alphabets.   But there
  151.        seems to be no standard way to define  them  or  determine
  152.        their contents.  Therefore, they are not fully implemented
  153.        in GNU ttrr; each  character's  equivalence  class  consists
  154.        only  of  that  character, which makes this a useless con-
  155.        struction currently.
  156.  
  157.    TTRRAANNSSLLAATTIINNGG
  158.        ttrr performs translation when _s_t_r_i_n_g_1 and _s_t_r_i_n_g_2 are  both
  159.        given  and  the  --delete  (_-_d)  option  is not given.  ttrr
  160.        translates each character of its input that is in set1  to
  161.        the  corresponding  character  in set2.  Characters not in
  162.        set1 are  passed  through  unchanged.   When  a  character
  163.        appears more than once in set1 and the corresponding char-
  164.        acters in set2 are not all the same, only the final one is
  165.        used.  For example, these two commands are equivalent:
  166.               tr aaa xyz
  167.               tr a z
  168.  
  169.        A  common  use of ttrr is to convert lowercase characters to
  170.        uppercase.  This can be done in many ways.  Here are three
  171.        of them:
  172.               tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  173.               tr a-z A-Z
  174.               tr '[:lower:]' '[:upper:]'
  175.  
  176.        When  ttrr  is  performing translation, set1 and set2 should
  177.        normally have the same length.  If set1  is  shorter  than
  178.        set2, the extra characters at the end of set2 are ignored.
  179.  
  180.        On the other hand, making set1 longer  than  set2  is  not
  181.        portable;  POSIX.2  says that the result is undefined.  In
  182.        this situation, the BSD ttrr pads set2 to the length of set1
  183.        by  repeating  the last character of set2 as many times as
  184.        necessary.  The System V ttrr truncates set1 to  the  length
  185.        of set2.
  186.  
  187.        By default, GNU ttrr handles this case like the BSD ttrr does.
  188.        When the --truncate-set1 (_-_t) option is given, GNU ttrr han-
  189.        dles  this case like the System V ttrr instead.  This option
  190.        is ignored for operations other than translation.
  191.  
  192.        Acting like the System  V  ttrr  in  this  case  breaks  the
  193.  
  194.  
  195.  
  196. FSF                     GNU Text Utilities                      3
  197.  
  198.  
  199.  
  200.  
  201.  
  202. TR(1L)                                                     TR(1L)
  203.  
  204.  
  205.        relatively common BSD idiom:
  206.               tr -cs A-Za-z0-9 '\012'
  207.        because  it converts only zero bytes (the first element in
  208.        the  complement   of   set1),   rather   than   all   non-
  209.        alphanumerics, to newlines.
  210.  
  211.    SSQQUUEEEEZZIINNGG RREEPPEEAATTSS AANNDD DDEELLEETTIINNGG
  212.        When  given  just the --delete (_-_d) option, ttrr removes any
  213.        input characters that are in set1.
  214.  
  215.        When given just  the  --squeeze-repeats  (_-_s)  option,  ttrr
  216.