Purpose:Display the beginning of the specified file(s)

 

Format:HEAD [/= /A:[[-][+]rhsadecijopt] /B /Cn /I"text" /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 names of the files to display, one per line (see @file lists for details).

 

/A: (Attribute select)

/O:... (Order)

/B(ell)

/P(ause)

/C (number of bytes)

/Q(uiet)

/I"text" (match description)

/V(erbose)

/N(umber of lines)


 

See also: LIST, TAIL, and TYPE.

 

File Selection

 

Supports command dialog, attribute switches, extended wildcards, ranges, multiple file names, and include lists.

 

Internet: Can be used with FTP/HTTP Servers, e.g.

 

head "https://jpsoft.com/notfound.htm"

 

Usage:

 

The HEAD command displays the first 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 HEAD because they include non-alphanumeric characters or unusual line separators.

 

You can press Ctrl-S to pause HEAD's display and then any key to continue.

 

The following example displays the first 15 lines of the files MEMO1 and MEMO2:

 

head /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, HEAD will display its command dialog.

 

HEAD sets two internal variables:

 

%_head_filesThe number of files displayed
%_head_errorsThe number of errors

 

HEAD will recognize Unicode (UTF-16) files based on either a BOM or specific UTF-16 sequences at the beginning of the file. HEAD will recognize UTF-8 files based on either a BOM or UTF-8 extended characters within the first 2K of the file.

 

FTP Usage

 

HEAD can also display files on FTP/HTTP Servers. For example:

 

head ftp://ftp.microsoft.com/index

 

NTFS File Streams

 

HEAD supports file streams on NTFS drives. You can type an individual stream by specifying the stream name, for example:

 

head streamfile:s1

 

Options:

 

/=Display the HEAD 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:Select only those files that have the specified attribute(s) set. See Attribute Switches for information on the attributes which can follow /A:. Do not use /A: with @file lists. See @file lists for details.

 

You can specify /A:= to display a dialog to help you set individual attributes.

 

/BIgnore bell (ASCII 7) characters.

 

/C: Display the specified number of bytes. /C accepts a b, k, or m modifiers at the end of the number. b is the number of 512-byte blocks, k is the number of kilobytes, and m the number of megabytes.

 

/I"text"Select files by matching text in their descriptions. The text can include wildcards and extended wildcards. The search text must be enclosed in double quotes, and must follow the /I immediately, with no intervening spaces. You can select all filenames that have a description with /I"[?]*", or all filenames that do not have a description with /I"[]". Do not use /I with @file lists. See @file lists for details.

 

/N+nSkip the first n lines.

 

/N nDisplay n lines. The default is 10.

 

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