342 lines
12 KiB
HTML
342 lines
12 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>tail</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="tail"></a> <a name="tag_04_137"></a><!-- tail -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_137_01"></a>NAME</h4>
|
|
|
|
<blockquote>tail - copy the last part of a file</blockquote>
|
|
|
|
<h4><a name="tag_04_137_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>tail</tt> <b>[</b><tt>-f</tt><b>][</b> <tt>-c</tt> <i>number</i><tt>| -n</tt> <i>number</i><b>][</b><i>file</i><b>]</b></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>tail</i> utility shall copy its input file to the standard output beginning at a designated place.</p>
|
|
|
|
<p>Copying shall begin at the point in the file indicated by the <b>-c</b> <i>number</i> or <b>-n</b> <i>number</i> options. The
|
|
option-argument <i>number</i> shall be counted in units of lines or bytes, according to the options <b>-n</b> and <b>-c</b>. Both
|
|
line and byte counts start from 1.</p>
|
|
|
|
<p>Tails relative to the end of the file may be saved in an internal buffer, and thus may be limited in length. Such a buffer, if
|
|
any, shall be no smaller than {LINE_MAX}*10 bytes.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>tail</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
|
|
|
|
<p>The following options shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>-c </b> <i>number</i></dt>
|
|
|
|
<dd>The application shall ensure that the <i>number</i> option-argument is a decimal integer whose sign affects the location in the
|
|
file, measured in bytes, to begin the copying:
|
|
|
|
<center>
|
|
<table border="1" cellpadding="3" align="center">
|
|
<tr valign="top">
|
|
<th align="center">
|
|
<p class="tent"><b>Sign</b></p>
|
|
</th>
|
|
<th align="center">
|
|
<p class="tent"><b>Copying Starts</b></p>
|
|
</th>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="center">
|
|
<p class="tent">+</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Relative to the beginning of the file.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="center">
|
|
<p class="tent">-</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Relative to the end of the file.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="center">
|
|
<p class="tent"><i>none</i></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Relative to the end of the file.</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
|
|
<p>The origin for counting shall be 1; that is, <b>-c</b> +1 represents the first byte of the file, <b>-c</b> -1 the last.</p>
|
|
</dd>
|
|
|
|
<dt><b>-f</b></dt>
|
|
|
|
<dd>If the input file is a regular file or if the <i>file</i> operand specifies a FIFO, do not terminate after the last line of the
|
|
input file has been copied, but read and copy further bytes from the input file when they become available. If no <i>file</i>
|
|
operand is specified and standard input is a pipe, the <b>-f</b> option shall be ignored. If the input file is not a FIFO, pipe, or
|
|
regular file, it is unspecified whether or not the <b>-f</b> option shall be ignored.</dd>
|
|
|
|
<dt><b>-n </b> <i>number</i></dt>
|
|
|
|
<dd>This option shall be equivalent to <b>-c</b> <i>number</i>, except the starting location in the file shall be measured in lines
|
|
instead of bytes. The origin for counting shall be 1; that is, <b>-n</b> +1 represents the first line of the file, <b>-n</b> -1 the
|
|
last.</dd>
|
|
</dl>
|
|
|
|
<p>If neither <b>-c</b> nor <b>-n</b> is specified, <b>-n</b> 10 shall be assumed.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operand shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>file</i></dt>
|
|
|
|
<dd>A pathname of an input file. If no <i>file</i> operands are specified, the standard input shall be used.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard input shall be used only if no <i>file</i> operands are specified. See the INPUT FILES section.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>If the <b>-c</b> option is specified, the input file can contain arbitrary data; otherwise, the input file shall be a text
|
|
file.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>tail</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>LANG</i></dt>
|
|
|
|
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
|
|
|
|
<dt><i>LC_ALL</i></dt>
|
|
|
|
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
|
|
|
|
<dt><i>LC_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments and input files).</dd>
|
|
|
|
<dt><i>LC_MESSAGES</i></dt>
|
|
|
|
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
|
|
error.</dd>
|
|
|
|
<dt><i>NLSPATH</i></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>The designated portion of the input file shall be written to standard output.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>Successful completion.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_137_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>The <b>-c</b> option should be used with caution when the input is a text file containing multi-byte characters; it may produce
|
|
output that does not start on a character boundary.</p>
|
|
|
|
<p>Although the input file to <i>tail</i> can be any type, the results might not be what would be expected on some character
|
|
special device files or on file types not described by the System Interfaces volume of IEEE Std 1003.1-2001. Since this
|
|
volume of IEEE Std 1003.1-2001 does not specify the block size used when doing input, <i>tail</i> need not read all of
|
|
the data from devices that only perform block transfers.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The <b>-f</b> option can be used to monitor the growth of a file that is being written by some other process. For example, the
|
|
command:</p>
|
|
|
|
<pre>
|
|
<tt>tail -f fred
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>prints the last ten lines of the file <b>fred</b>, followed by any lines that are appended to <b>fred</b> between the time
|
|
<i>tail</i> is initiated and killed. As another example, the command:</p>
|
|
|
|
<pre>
|
|
<tt>tail -f -c 15 fred
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>prints the last 15 bytes of the file <b>fred</b>, followed by any bytes that are appended to <b>fred</b> between the time
|
|
<i>tail</i> is initiated and killed.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>This version of <i>tail</i> was created to allow conformance to the Utility Syntax Guidelines. The historical <b>-b</b> option
|
|
was omitted because of the general non-portability of block-sized units of text. The <b>-c</b> option historically meant
|
|
"characters", but this volume of IEEE Std 1003.1-2001 indicates that it means "bytes". This was selected to allow
|
|
reasonable implementations when multi-byte characters are possible; it was not named <b>-b</b> to avoid confusion with the
|
|
historical <b>-b</b>.</p>
|
|
|
|
<p>The origin of counting both lines and bytes is 1, matching all widespread historical implementations.</p>
|
|
|
|
<p>The restriction on the internal buffer is a compromise between the historical System V implementation of 4096 bytes and the BSD
|
|
32768 bytes.</p>
|
|
|
|
<p>The <b>-f</b> option has been implemented as a loop that sleeps for 1 second and copies any bytes that are available. This is
|
|
sufficient, but if more efficient methods of determining when new data are available are developed, implementations are encouraged
|
|
to use them.</p>
|
|
|
|
<p>Historical documentation indicates that <i>tail</i> ignores the <b>-f</b> option if the input file is a pipe (pipe and FIFO on
|
|
systems that support FIFOs). On BSD-based systems, this has been true; on System V-based systems, this was true when input was
|
|
taken from standard input, but it did not ignore the <b>-f</b> flag if a FIFO was named as the <i>file</i> operand. Since the
|
|
<b>-f</b> option is not useful on pipes and all historical implementations ignore <b>-f</b> if no <i>file</i> operand is specified
|
|
and standard input is a pipe, this volume of IEEE Std 1003.1-2001 requires this behavior. However, since the <b>-f</b>
|
|
option is useful on a FIFO, this volume of IEEE Std 1003.1-2001 also requires that if standard input is a FIFO or a FIFO
|
|
is named, the <b>-f</b> option shall not be ignored. Although historical behavior does not ignore the <b>-f</b> option for other
|
|
file types, this is unspecified so that implementations are allowed to ignore the <b>-f</b> option if it is known that the file
|
|
cannot be extended.</p>
|
|
|
|
<p>This was changed to the current form based on comments noting that <b>-c</b> was almost never used without specifying a number
|
|
and that there was no need to specify <b>-l</b> if <b>-n</b> <i>number</i> was given.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="head.html"><i>head</i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_137_22"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The obsolescent SYNOPSIS lines and associated text are removed.</p>
|
|
|
|
<p>The normative text is reworded to avoid use of the term "must" for application requirements.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|