Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents

file(1) OSS Shell and Utilities Reference Manual
NAME
file - Determines file type from file content
SYNOPSIS
file file ...
DESCRIPTION
The file command reads files, performs a series of tests on each one, and attempts to classify them
by type. file then writes the file types to standard output.
The file utility uses the following steps to determine the type of a file:
• Uses the stat( ) function to determine if the file operand is a regular file or a special file
such as a directory, a named pipe (FIFO), or a file in the Guardian file system.
• Checks regular files to determine if they are HP-generated object files.
• Examines the first 512 bytes of object files other than HP object files to determine the file
type; uses the /etc/magic file to check for magic values.
• Invokes a Guardian procedure call for Guardian text files to retrieve the Guardian specific
file attributes, file type, and file code.
If a file appears to be plain text, file examines the first 512 bytes and tries to determine what kind
of text it is. If the first 512 bytes only contain ASCII characters, file returns either ASCII text or
English text. If the file contains other characters (that is, European or Asian xtended charac-
ters), file returns data.Ifafile does not appear to be plain text, file attempts to distinguish a
binary data file from a text file that contains extended characters.
/etc/magic File
The file command uses the /etc/magic file to identify files that have a magic number (that is, con-
tain a string constant that indicates type).
The following magic values are supported:
Table 3−1. Supported Magic Values
__________________________________________________________
Byte Offset Value Type Magic Value Printed String
__________________________________________________________
0 short 070707 cpio archive
0 string 070707 ASCII cpio archive
0 string %! PostScript document
0 string <MakerFile FrameMaker document
0 string <MIFFile FrameMaker MIF file
0 string <MML FrameMaker MML file
0 string !<arch> archive
257 string ustar tar archive
40 string SunBin Sun binary
__________________________________________________________
You can add other magic values to the /etc/magic file.
Use on Guardian Objects
Specify Guardian files with the /G pathname convention.
The file command uses the stat( ) function to determine the file type. Guardian processes with sub-
type 30 are identified as character special files. Guardian pathnames consisting of only /G,
volume names, or subvolume names are identified as directory. Guardian nondisk devices and
processes that are not of subtype 30 are identified as block special.
For disk files, the file utility checks the file format and returns its type. The file utility can only
detect object files created by HP compilers and tools. Object files generated by other sources are
3−134 Hewlett-Packard Company 527188-003