The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<html><head><title>tr</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
</head>
<body class='pod'>
<!--
  generated by Pod::Simple::HTML v3.01,
  using Pod::Simple::PullParser v2.02,
  under Perl v5.008002 at Thu Aug  5 13:56:18 2004 GMT.

 If you want to change this HTML document, you probably shouldn't do that
   by changing it directly.  Instead, see about changing the calling options
   to Pod::Simple::HTML, and/or subclassing Pod::Simple::HTML,
   then reconverting this document from the Pod source.
   When in doubt, email the author of Pod::Simple::HTML for advice.
   See 'perldoc Pod::Simple::HTML' for more info.

-->

<!-- start doc -->
<a name='___top' class='dummyTopAnchor' ></a>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

<p>tr - translate or delete characters</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>

<p>tr [ -cdsUC ] [ <i>SEARCHLIST</i> [ <i>REPLACEMENTLIST</i> ] ]</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>

<p>The <i>tr</i> program copies the standard input to the standard output with substitution or deletion of selected characters.
Input characters found in <i>SEARCHLIST</i> are mapped into the corresponding characters of <i>REPLACEMENTLIST</i>.
When <i>REPLACEMENTLIST</i> is short it is padded to the length of <i>SEARCHLIST</i> by duplicating its last character.</p>

<p>Here are the options:</p>

<dl>
<dt><a name="c"
>c</a></dt><p class="pad"></p>

<dd>Complement the SEARCHLIST.</dd><p class="pad"></p>

<dt><a name="d"
>d</a></dt><p class="pad"></p>

<dd>Delete found but unreplaced characters.</dd><p class="pad"></p>

<dt><a name="s"
>s</a></dt><p class="pad"></p>

<dd>Squash duplicate replaced characters.</dd><p class="pad"></p>

<dt><a name="U"
>U</a></dt><p class="pad"></p>

<dd>Translate to/from UTF-8.</dd><p class="pad"></p>

<dt><a name="C"
>C</a></dt><p class="pad"></p>

<dd>Translate to/from 8-bit char (octet).</dd><p class="pad"></p>
</dl>

<p>In either string,
the notation <code lang='und' xml:lang='und'>a-b</code> means a range of characters from <code lang='und' xml:lang='und'>a</code> to <code lang='und' xml:lang='und'>b</code> in increasing ASCII order.
Customary Perl escapes are honored,
such as <code lang='und' xml:lang='und'>\n</code> for newline,
<code lang='und' xml:lang='und'>\012</code> for octal,
and <code lang='und' xml:lang='und'>\x0A</code> for hexadecimal codes.</p>

<p>If the <b>-c</b> flag is specified,
the SEARCHLIST character set is complemented.
If the <b>-d</b> flag is specified,
any characters specified by SEARCHLIST not found in REPLACEMENTLIST are deleted.
(Note that this is slightly more flexible than the behavior of some tr programs,
which delete anything they find in the SEARCHLIST,
period.) If the <b>-s</b> flag is specified,
sequences of characters that were transliterated to the same character are squashed down to a single instance of the character.</p>

<p>If the <b>-d</b> flag is used,
the REPLACEMENTLIST is always interpreted exactly as specified.
Otherwise,
if the REPLACEMENTLIST is shorter than the SEARCHLIST,
the final character is replicated till it is long enough.
If the REPLACEMENTLIST is empty,
the SEARCHLIST is replicated.
This latter is useful for counting characters in a class or for squashing character sequences in a class.</p>

<p>The first <b>-U</b> or <b>-C</b> flag applies to the left side of the translation.
The second one applies to the right side.
If present,
these flags override the current utf8 state.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="EXAMPLES"
>EXAMPLES</a></h1>

<p>The following command creates a list of all the words in <em lang='und' xml:lang='und'>file1</em> one per line in <em lang='und' xml:lang='und'>file2</em>,
where a word is taken to be a maximal string of alphabetics.</p>

<pre lang='und' xml:lang='und'>    tr -cs A-Za-z &#34;\n&#34; &#60;file1 &#62;file2</pre>

<p>The following command strips the 8th bit from an input file:</p>

<pre lang='und' xml:lang='und'>    tr &#34;\200-\377&#34; &#34;\000-\177&#34;</pre>

<p>The following command translates Latin-1 to Unicode:</p>

<pre lang='und' xml:lang='und'>    tr -CU &#34;\0-\xFF&#34; &#34;&#34; </pre>

<p>The following command translates Unicode to Latin-1</p>

<pre lang='und' xml:lang='und'>    tr -UC &#34;\0-\x{FF}&#34; &#34;&#34; </pre>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NOTE"
>NOTE</a></h1>

<p>This command is implemented using Perl&#39;s <code lang='und' xml:lang='und'>tr</code> operator. See the documentation in <a href="http://search.cpan.org/perldoc?perlop" class="podlinkpod"
>perlop</a> for details on its operation.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="BUGS"
>BUGS</a></h1>

<p>There is no way to catch the file open error on ARGV handle processing, so the exit status does not reflect file open failures.</p>

<p>Not all systems have Unicode support yet, in which case the <b>-U</b> or <b>-C</b> flags would cause a fatal error.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="AUTHOR"
>AUTHOR</a></h1>

<p>Tom Christiansen, <i>tchrist@perl.com</i>.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="COPYRIGHT_and_LICENSE"
>COPYRIGHT and LICENSE</a></h1>

<p>This program is copyright (c) Tom Christiansen 1999.</p>

<p>This program is free and open software. You may use, modify, distribute, and sell this program (and any modified variants) in any way you wish, provided you do not restrict others from doing the same.</p>

<!-- end doc -->

</body></html>