upload html manpage
[hband-tools.git] / tabdata / td-alter.html
blob9ba1d48975fb7c874c1b0e8a83f3a89ae2aeeca2
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>td-alter - Add new columns and fields to tabular data stream, and modify value of existing fields.</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:root@localhost" />
8 </head>
10 <body>
14 <ul id="index">
15 <li><a href="#NAME">NAME</a></li>
16 <li><a href="#USAGE">USAGE</a></li>
17 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
18 <li><a href="#EXAMPLES">EXAMPLES</a></li>
19 <li><a href="#OPTIONS">OPTIONS</a></li>
20 <li><a href="#REFERENCES">REFERENCES</a></li>
21 </ul>
23 <h1 id="NAME">NAME</h1>
25 <p>td-alter - Add new columns and fields to tabular data stream, and modify value of existing fields.</p>
27 <h1 id="USAGE">USAGE</h1>
29 <p>td-alter <i>COLUMN</i>=<i>EXPR</i> [<i>COLUMN</i>=<i>EXPR</i> [<i>COLUMN</i>=<i>EXPR</i> [...]]]</p>
31 <h1 id="DESCRIPTION">DESCRIPTION</h1>
33 <p>On each data row, sets field in <i>COLUMN</i> to the value resulted by <i>EXPR</i> Perl expression.</p>
35 <p>In <i>EXPR</i>, you may refer to other fields by <code>$F{NAME}</code> where <i>NAME</i> is the column name; or by <code>$F[INDEX]</code> where <i>INDEX</i> is the 0-based column index number. Furthermore you may refer to uppercase alpha-numeric field names, simply by bareword <code>COLUMN</code>, well, enclosed in paretheses like <code>(COLUMN)</code> to avoid parsing unambiguity in Perl. It&#39;s possible because these column names are set up as subroutines internally.</p>
37 <p>Topic variable (<code>$_</code>) initially is set to the current value of <i>COLUMN</i> in <i>EXPR</i>. So for example <code>N=&#39;-$_&#39;</code> makes the field N the negative of itself.</p>
39 <p>You can create new columns simply by referring to a <i>COLUMN</i> name that does not exist yet. You can refer to an earlier defined <i>COLUMN</i> in subsequent <i>EXPR</i> expressions.</p>
41 <h1 id="EXAMPLES">EXAMPLES</h1>
43 <p>Add new columns: TYPE and IS_BIGFILE. IS_BIGFILE depends on previously defined TYPE field.</p>
45 <pre><code>ls -l | td-trans-ls | td-alter TYPE=&#39;substr MODE,0,1&#39; IS_BIGFILE=&#39;SIZE&gt;10000000 &amp;&amp; TYPE ne &quot;d&quot; ? &quot;yes&quot; : &quot;no&quot;&#39;</code></pre>
47 <p>Strip sub-seconds and timezone from DATETIME field:</p>
49 <pre><code>TIME_STYLE=full-iso ls -l | td-trans-ls | td-alter DATETIME=&#39;s/\..*//; $_&#39;</code></pre>
51 <h1 id="OPTIONS">OPTIONS</h1>
53 <dl>
55 <dt id="H---no--header">-H, --no--header</dt>
56 <dd>
58 <p>do not show headers</p>
60 </dd>
61 <dt id="h---header">-h, --header</dt>
62 <dd>
64 <p>show headers (default)</p>
66 </dd>
67 </dl>
69 <h1 id="REFERENCES">REFERENCES</h1>
71 <p>&quot;Alter&quot; in td-alter comes from SQL. td-alter(1) can change the &quot;table&quot; column layout. But contrary to SQL&#39;s ALTER TABLE, td-alter(1) can modify the records too, so akin to SQL UPDATE as well.</p>
74 </body>
76 </html>