Difference between revisions of "32v 1m tr"

From Computer History Wiki
Jump to: navigation, search
(New page: TR(1) UNIX Programmer's Manual TR(1) == NAME == tr - translate characters == SYNOPSIS == tr [ -cds ] [ string1 [ string2 ] ] == DESCRIPTION == ...)
 
m (SEE ALSO)
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
  
 
== NAME ==
 
== NAME ==
    tr - translate characters
+
tr - translate characters
  
 
== SYNOPSIS ==
 
== SYNOPSIS ==
    tr [ -cds ] [ string1 [ string2 ] ]
+
tr [ -cds ] [ string1 [ string2 ] ]
  
 
== DESCRIPTION ==
 
== DESCRIPTION ==
    _T_r copies the standard input to the standard output with
+
'''Tr''' copies the standard input to the standard output with
    substitution or deletion of selected characters.  Input
+
substitution or deletion of selected characters.  Input
    characters found in _s_t_r_i_n_g_1 are mapped into the correspond-
+
characters found in '''string1''' are mapped into the corresponding characters of '''string2'''.  When '''string2''' is short it is padded to the length of '''string1''' by duplicating its last character.  Any combination of the options -cds may be used: -c
    ing characters of _s_t_r_i_n_g_2.  When _s_t_r_i_n_g_2 is short it is pad-
+
complements the set of characters in '''string1''' with respect to
    ded to the length of _s_t_r_i_n_g_1 by duplicating its last charac-
+
the universe of characters whose ASCII codes are 01 through
    ter.  Any combination of the options -cds may be used: -c
+
0377 octal; -d deletes all input characters in '''string1'''; -s
    complements the set of characters in _s_t_r_i_n_g_1 with respect to
+
squeezes all strings of repeated output characters that are
    the universe of characters whose ASCII codes are 01 through
+
in '''string2''' to single characters.
    0377 octal; -d deletes all input characters in _s_t_r_i_n_g_1; -s
 
    squeezes all strings of repeated output characters that are
 
    in _s_t_r_i_n_g_2 to single characters.
 
  
    In either string the notation _a-_b means a range of charac-
+
In either string the notation _a-_b means a range of characters from _a to _b in increasing ASCII order.  The character
    ters from _a to _b in increasing ASCII order.  The character
+
`\' followed by 1, 2 or 3 octal digits stands for the character whose ASCII code is given by those digits.  A `\' followed by any other character stands for that character.
    `\' followed by 1, 2 or 3 octal digits stands for the char-
 
    acter whose ASCII code is given by those digits.  A `\' fol-
 
    lowed by any other character stands for that character.
 
  
    The following example creates a list of all the words in
+
The following example creates a list of all the words in
    `file1' one per line in `file2', where a word is taken to be
+
`file1' one per line in `file2', where a word is taken to be
    a maximal string of alphabetics.  The second string is
+
a maximal string of alphabetics.  The second string is
    quoted to protect `\' from the Shell.  012 is the ASCII code
+
quoted to protect `\' from the Shell.  012 is the ASCII code
    for newline.
+
for newline.
  
          tr -cs A-Za-z '\012' <file1 >file2
+
tr -cs A-Za-z '\012' <file1 >file2
  
 
== SEE ALSO ==
 
== SEE ALSO ==
    [[32v 1m ed|ed(1)]], [[32v 7m ascii|ascii(7)]]
+
[[32v 1m ed|ed(1)]], [[32v 7m ascii|ascii(7)]]
  
 
== BUGS ==
 
== BUGS ==
    Won't handle ASCII NUL in _s_t_r_i_n_g_1 or _s_t_r_i_n_g_2; always deletes
+
Won't handle ASCII NUL in '''string1''' or '''string2'''; always deletes NUL from input.
    NUL from input.
 
  
 
[[Category:32v man section 1]]
 
[[Category:32v man section 1]]

Latest revision as of 15:34, 4 January 2010

TR(1) UNIX Programmer's Manual TR(1)


NAME

tr - translate characters

SYNOPSIS

tr [ -cds ] [ string1 [ string2 ] ]

DESCRIPTION

Tr copies the standard input to the standard output with substitution or deletion of selected characters. Input characters found in string1 are mapped into the corresponding characters of string2. When string2 is short it is padded to the length of string1 by duplicating its last character. Any combination of the options -cds may be used: -c complements the set of characters in string1 with respect to the universe of characters whose ASCII codes are 01 through 0377 octal; -d deletes all input characters in string1; -s squeezes all strings of repeated output characters that are in string2 to single characters.

In either string the notation _a-_b means a range of characters from _a to _b in increasing ASCII order. The character `\' followed by 1, 2 or 3 octal digits stands for the character whose ASCII code is given by those digits. A `\' followed by any other character stands for that character.

The following example creates a list of all the words in `file1' one per line in `file2', where a word is taken to be a maximal string of alphabetics. The second string is quoted to protect `\' from the Shell. 012 is the ASCII code for newline.

tr -cs A-Za-z '\012' <file1 >file2

SEE ALSO

ed(1), ascii(7)

BUGS

Won't handle ASCII NUL in string1 or string2; always deletes NUL from input.