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} ...

 

fileThe file or list of files that you want to display
@fileA text file containing the name of a file to display in each line (see @file lists for details)

 

/A: (Attribute select)/N(umber of lines)
/B(ell)/O:... (Order)
/C (number of bytes)/P(ause)
/F(ollow)/Q(uiet)
/I"text" (description range)/V(erbose)
/N+x (skip x lines before display)

 

See also: HEAD, LIST, and TYPE.

 

File Selection

 

Supports command dialog, 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. See Highlighting and Copying Text for additional information on CLIP:.

 

If you don't enter any arguments, TAIL will display its command dialog.

 

TAIL sets two internal variables:

 

%_tail_filesThe number of files displayed
%_tail_errorsThe 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 xxxdisplays the last 5 lines of file xxx
tail /n+20 /n 999999 xxxskip 20 lines, then display 999999 lines of xxx
tail /n+1001 /n 1 xxxskip 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:

 

/=Display the TAIL command dialog to help you set the filename and command line options. The /= option can be anywhere on the line; additional options will set the appropriate fields in the command dialog.

 

/A:[attributelist]
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.

 

/BIgnore bell (ASCII 7) characters.

 

/Cnn[b|k|m]
Display nn bytes, 512-byte blocks, kilobytes, or megabytes.

 

/FContinuously monitor the file and display new lines until the command is interrupted, e.g, using Ctrl-C or Ctrl-Break..

 

/I"text"
Select files by a descriptor range. See the link for details.

 

/N nDisplay 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.

 

/N+xSkip x lines from the beginning of the file, then start displaying lines. If the /N+ option is specified without specifying x, the option is ignored. This option does not affect the number of lines displayed (unless the start line is too close to the end of file)

 

Example:        TAIL /N+5 file        will display 10 lines (the default) after skipping 5 lines.

 

/O:...Sort the files before processing.

 

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:

 

nSort by filename and extension, unless e is explicitly included.
-Reverse the sort order for the next sort key
aSort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension.
cSort by compression ratio
dSort by date and time (oldest first); also see /T:acw
eSort by extension
gGroup subdirectories first, then files
iSort by description
oSort by owner
rReverse the sort order for all options
sSort by size
tSame as d
uUnsorted
zSame as s

 

/PPause and prompt after displaying each page.

 

/QDo 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.

 

/VDisplay a header for each file.