TAIL |
Purpose: | Display the end of the specified file(s) |
Format: | TAIL [range ... [/I"text"]] [/A:[attrlist] /B /Cnn /F /N+x /N[ ]n /O:[-]acdeginorstuz /P /Q /V] {@file | file} ... |
file | The file or list of files that you want to display |
@file | A text file containing the name of a file to display in each line (see @file lists for details) |
See also: HEAD, LIST, and TYPE.
File Selection
Supports extended wildcards, ranges, multiple file names, and include lists.
Internet: Can be used with FTP servers, including HTTP/HTTPS files, e.g.
tail "https://jpsoft.com/notfound.htm"
Usage:
The TAIL command displays the last part of a file or files. It is normally only useful for displaying ASCII text files (i.e. alphanumeric characters arranged in lines separated by CR/LF). Executable files (.EXE) and many data files may be unreadable when displayed with TAIL because they include non-alphanumeric characters or unusual line separators.
You can press Ctrl-S to pause TAIL's display and then any key to continue.
The following example displays the last 15 lines of the files MEMO1 and MEMO2:
tail /n15 memo1 memo2
To display text from the clipboard use CLIP: as the file name. CLIP: will not return any data if the clipboard does not contain text.
TAIL sets two internal variables:
%_tail_files | The number of files displayed |
%_tail_errors | The number of errors |
TAIL will recognize Unicode (UTF-16) files based on either a BOM or specific UTF-16 sequences at the beginning of the file. TAIL will recognize UTF-8 files based on either a BOM or UTF-8 extended characters within the first 2K of the file.
•FTP Usage
TAIL can also display files on FTP servers. For example:
tail "ftp://ftp.microsoft.com/index"
You can also use the IFTP command to start an FTP session on a server, and then use an abbreviated syntax to specify the files and directories you want.
•NTFS File Streams
TAIL supports file streams on NTFS drives. You can type an individual stream by specifying the stream name, for example:
tail streamfile:s1
•Pipes
TAIL can optionally be used with an input pipe. For example:
dir | tail /n2
This is not ordinarily feasible in Windows because pipes can't be "rewound", and therefore the pipe has to be written to a temporary memory buffer and the TAIL taken from there. Consequently, this limits the amount you can actually display in TAIL to less than a million bytes when the input is piped.
Examples:
tail /n 5 xxx | displays the last 5 lines of file xxx |
tail /n+20 /n 999999 xxx | skip 20 lines, then display 999999 lines of xxx |
tail /n+1001 /n 1 xxx | skip 1001 lines, then display 1 line of xxx |
set x=%@execstr[tail /n+1001 /n 1 xxx] | sets x to the contents of line 1002 of xxx |
set x=%@execstr[tail /n 2 xxx] | sets x to the contents of the penultimate line of xxx |
Options:
Select only those files that match the specified attribute(s).See Attribute Switches for details. |
You can specify /A:= to display a dialog to help you set individual attributes.
Display nn bytes, 512-byte blocks, kilobytes, or megabytes. |
/F | Continuously monitor the file and display new lines until the command is interrupted, e.g, using Ctrl-C or Ctrl-Break.. |
Select files by a descriptor range. See the link for details. |
/N n | Display n lines. The default is 10. Space between the option switch /N and the number n is optional. If /N is specified without n, it is equivalent to specifying 0 lines to be displayed, and the command will not generate output, unless /V is also specified. |
Example: TAIL /N+5 file will display 10 lines (the default) after skipping 5 lines. |
You may use any combination of the sorting options below. If multiple options are used, the listing will be sorted with the first sort option as the primary key, the next as the secondary key, and so on:
n | Sort by filename and extension, unless e is explicitly included. This is the default. |
- | Reverse the sort order for the next sort key |
a | Sort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension. |
c | Sort by compression ratio |
d | Sort by date and time (oldest first); also see /T:acw |
e | Sort by extension |
g | Group subdirectories first, then files |
i | Sort by description |
o | Sort by owner |
r | Reverse the sort order for all options |
s | Sort by size |
t | Same as d |
u | Unsorted |
z | Same as s |
/Q | Do not display a header for each file. This is the default behavior, but an explicit /Q may be needed to override an alias that forces /V. |