1file(1)                          User Commands                         file(1)
2
3
4

NAME

6       file - determine file type
7

SYNOPSIS

9       /usr/bin/file [-dh] [-m mfile] [-M Mfile] [-f ffile] file...
10
11
12       /usr/bin/file [-dh] [-m mfile] [-M Mfile] -f ffile
13
14
15       /usr/bin/file -i [-h] [-f ffile] file...
16
17
18       /usr/bin/file -i [-h] -f ffile
19
20
21       /usr/bin/file -c [-d] [-m mfile] [-M Mfile]
22
23
24       /usr/xpg4/bin/file [-dh] [-m mfile] [-M Mfile] [-f ffile] file...
25
26
27       /usr/xpg4/bin/file [-dh] [-m mfile] [-M Mfile] -f ffile
28
29
30       /usr/xpg4/bin/file -i [-h] [-f ffile] file...
31
32
33       /usr/xpg4/bin/file -i [-h] -f ffile
34
35
36       /usr/xpg4/bin/file -c [-d] [-m mfile] [-M Mfile]
37
38

DESCRIPTION

40       The  file  utility  performs a series of tests on each file supplied by
41       file and, optionally, on each file listed in ffile  in  an  attempt  to
42       classify  it. If the file is not a regular file, its file type is iden‐
43       tified. The file types directory, FIFO, block  special,  and  character
44       special  are  identified as such. If the file is a regular file and the
45       file is zero-length, it is identified as an empty file.
46
47
48       If file appears to be a text file, file examines the  first  512  bytes
49       and  tries to determine its programming language. If file is a symbolic
50       link, by default the link is followed and file tests the file to  which
51       the symbolic link refers.
52
53
54       If  file  is  a  relocatable object, executable, or shared object, file
55       prints out information about the file's  execution  requirements.  This
56       information  includes  the machine class, byte-ordering, static/dynamic
57       linkage, and any software or hardware capability requirements. If  file
58       is  a runtime linking configuration file, file prints information about
59       the target platform, including the machine class and byte-ordering.
60
61
62       By  default,  file  will  try  to  use   the   localized   magic   file
63       /usr/lib/locale/locale/LC_MESSAGES/magic,  if  it  exists,  to identify
64       files that have a magic number. For example, in  the  Japanese  locale,
65       file  will try to use /usr/lib/locale/ja/LC_MESSAGES/magic. If a local‐
66       ized magic file does not exist, file will utilize /etc/magic.  A  magic
67       number  is  a  numeric or string constant that indicates the file type.
68       See magic(4) for an explanation of the format of /etc/magic.
69
70
71       If file does not exist, cannot be read, or its file status could not be
72       determined, it is not considered an error that affects the exit status.
73       The output will indicate that the file was processed, but that its type
74       could not be determined.
75

OPTIONS

77       The following options are supported:
78
79       -c          Checks  the  magic  file  for format errors. For reasons of
80                   efficiency, this validation is normally not carried out.
81
82
83       -d          Applies  any   position-sensitive   and   context-sensitive
84                   default system tests to the file.
85
86
87       -f ffile    ffile contains a list of the files to be examined.
88
89
90       -h          When a symbolic link is encountered, this option identifies
91                   the file as a symbolic link. If -h  is  not  specified  and
92                   file is a symbolic link that refers to a non-existent file,
93                   the file utility identifies the file as a symbolic link, as
94                   if -h had been specified.
95
96
97       -i          If  a  file is a regular file, this option does not attempt
98                   to classify the type of file further,  but  identifies  the
99                   file as a "regular file".
100
101
102       -m mfile
103                   /usr/bin/file         Uses  mfile  as  an  alternate  magic
104                                         file, instead of /etc/magic.
105
106
107                   /usr/xpg4/bin/file    Specifies the name of a file contain‐
108                                         ing position-sensitive tests that are
109                                         applied to a file in order  to  clas‐
110                                         sify  it  (see  magic(4)).  If the -m
111                                         option is specified without  specify‐
112                                         ing  the  -d option or the -M option,
113                                         position-sensitive   default   system
114                                         tests are applied after the position-
115                                         sensitive tests specified by  the  -m
116                                         option.
117
118
119
120       -M Mfile    Specifies  the name of a file containing position-sensitive
121                   tests that are applied to a file in order  to  classify  it
122                   (see  magic(4)). No position-sensitive default system tests
123                   nor context-sensitive  default  system  tests  are  applied
124                   unless the -d option is also specified.
125
126
127
128       If  the  -M  option  is specified with the -d option, the -m option, or
129       both, or if the -m option is specified with the -d option, the concate‐
130       nation  of  the  position-sensitive tests specified by these options is
131       applied in the order specified by the appearance of these options.
132

OPERANDS

134       The following operands are supported:
135
136       file    A path name of a file to be tested.
137
138

USAGE

140       See largefile(5) for the description  of  the  behavior  of  file  when
141       encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
142

EXAMPLES

144       Example 1 Determining if an Argument is a Binary Executable Files
145
146
147       The  following  example determine if an argument is a binary executable
148       file:
149
150
151         file "$1" | grep −Fq executable &&
152                   printf "%s is executable.0 "$1"
153
154
155

ENVIRONMENT VARIABLES

157       See environ(5) for descriptions of the following environment  variables
158       that affect the execution of file: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
159       and NLSPATH.
160

EXIT STATUS

162       The following exit values are returned:
163
164       0     Successful completion.
165
166
167       >0    An error occurred.
168
169

FILES

171       /etc/magic    file's magic number file
172
173

ATTRIBUTES

175       See attributes(5) for descriptions of the following attributes:
176
177
178
179
180       ┌─────────────────────────────┬─────────────────────────────┐
181       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
182       ├─────────────────────────────┼─────────────────────────────┤
183       │Availability                 │SUNWcsu                      │
184       ├─────────────────────────────┼─────────────────────────────┤
185       │CSI                          │Enabled                      │
186       ├─────────────────────────────┼─────────────────────────────┤
187       │Interface Stability          │Standard                     │
188       └─────────────────────────────┴─────────────────────────────┘
189

SEE ALSO

191       crle(1), elfdump(1), ls(1), magic(4), attributes(5), environ(5), large‐
192       file(5), standards(5)
193
194
195
196SunOS 5.11                        15 May 2006                          file(1)
Impressum