xref: /openbsd-src/usr.bin/file/file.1 (revision 256dd039a4942ff2fefa40889cd2d8affb1fd0a2)
1*256dd039Sjca.\" $OpenBSD: file.1,v 1.44 2015/12/24 11:45:34 jca Exp $
2c1d344f8Saaron.\" $FreeBSD: src/usr.bin/file/file.1,v 1.16 2000/03/01 12:19:39 sheldonh Exp $
35d4f1f7eSjmc.\"
4ff772f70Snicm.\" Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
5a17093f1Sian.\" Copyright (c) Ian F. Darwin 1986-1995.
6a17093f1Sian.\" Software written by Ian F. Darwin and others;
7a17093f1Sian.\" maintained 1995-present by Christos Zoulas and others.
85d4f1f7eSjmc.\"
9a17093f1Sian.\" Redistribution and use in source and binary forms, with or without
10a17093f1Sian.\" modification, are permitted provided that the following conditions
11a17093f1Sian.\" are met:
12a17093f1Sian.\" 1. Redistributions of source code must retain the above copyright
13a17093f1Sian.\"    notice immediately at the beginning of the file, without modification,
14a17093f1Sian.\"    this list of conditions, and the following disclaimer.
15a17093f1Sian.\" 2. Redistributions in binary form must reproduce the above copyright
16a17093f1Sian.\"    notice, this list of conditions and the following disclaimer in the
17a17093f1Sian.\"    documentation and/or other materials provided with the distribution.
185d4f1f7eSjmc.\"
19a17093f1Sian.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20a17093f1Sian.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21a17093f1Sian.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22a17093f1Sian.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
23a17093f1Sian.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24a17093f1Sian.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25a17093f1Sian.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26a17093f1Sian.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27a17093f1Sian.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28a17093f1Sian.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29a17093f1Sian.\" SUCH DAMAGE.
305d4f1f7eSjmc.\"
31*256dd039Sjca.Dd $Mdocdate: December 24 2015 $
32c1d344f8Saaron.Dt FILE 1
33c1d344f8Saaron.Os
34c1d344f8Saaron.Sh NAME
35c1d344f8Saaron.Nm file
36c1d344f8Saaron.Nd determine file type
37c1d344f8Saaron.Sh SYNOPSIS
38ad0cc88dSajacoutot.Nm
3946bdcaf1Snicm.Op Fl bchiLsW
40ff772f70Snicm.Ar
41c1d344f8Saaron.Sh DESCRIPTION
4258398dbdSjaredyThe
43c1d344f8Saaron.Nm
44ff772f70Snicmutility tests each argument and attempts to determine its type.
45ff772f70SnicmThree sets of tests are performed:
46ff772f70Snicm.Bl -enum -offset Ds
47ff772f70Snicm.It
48ff772f70SnicmFilesystem tests, for example if a file is empty, or a special file such as a
49ff772f70Snicmsocket or named pipe (FIFO).
50ff772f70Snicm.It
51ff772f70Snicm.Dq Magic
52ff772f70Snicmtests for data in particular fixed formats.
53ff772f70SnicmThese are loaded from the
54ff772f70Snicm.Pa /etc/magic
55ff772f70Snicmfile (or
56ff772f70Snicm.Pa ~/.magic
571f298b31Snicminstead if it exists and
581f298b31Snicm.Nm
591f298b31Snicmis not running as root).
60ff772f70SnicmThe file format is described in
61ff772f70Snicm.Xr magic 5 .
62ff772f70Snicm.It
63ff772f70SnicmTests for text files such as plain ASCII or C programming language files.
64ff772f70Snicm.El
65c1d344f8Saaron.Pp
66ff772f70SnicmThe first test which succeeds causes the file type to be printed.
67ff772f70SnicmThe type will often contain one of the words
68ad0cc88dSajacoutot.Em text
69ff772f70Snicm(contains only printing characters and is probably safe to read on an ASCII
70ff772f70Snicmterminal),
71ad0cc88dSajacoutot.Em executable
72ff772f70Snicm(the file contains a compiled executable program)
73df930be7Sderaadtor
74ad0cc88dSajacoutot.Em data
75ff772f70Snicmmeaning anything else.
76442f81f7Sjmc.Pp
77acc3b7f0SnicmIf
78acc3b7f0Snicm.Ar file
79acc3b7f0Snicmis a single dash
80acc3b7f0Snicm.Pq Sq - ,
81acc3b7f0Snicm.Nm
82acc3b7f0Snicmreads from the standard input.
83acc3b7f0Snicm.Pp
84442f81f7SjmcThe options are as follows:
85ad0cc88dSajacoutot.Bl -tag -width indent
86*256dd039Sjca.It Fl b , -brief
8746bdcaf1SnicmDoes not prepend filenames to output lines.
88ff772f70Snicm.It Fl c
8946bdcaf1SnicmPrints a summary of the parsed magic file; usually used for debugging.
9046bdcaf1Snicm.It Fl h
9146bdcaf1SnicmCauses symlinks not to be followed.
92129dfa47SjmcThis is the default.
93ff772f70Snicm.It Fl i , -mime , -mime-type
94a9c90243SjmcOutputs MIME type strings rather than the more
95ff772f70Snicmtraditional human-readable ones.
96ad0cc88dSajacoutotThus it may say
97ff772f70Snicm.Dq text/plain
98ad0cc88dSajacoutotrather than
99ad0cc88dSajacoutot.Dq ASCII text .
100*256dd039Sjca.It Fl L , -dereference
101ff772f70SnicmCauses symlinks to be followed.
102ff772f70Snicm.It Fl s
103a9c90243SjmcAttempts to read block and character device files, not just regular files.
104ff772f70Snicm.It Fl W
10546bdcaf1SnicmDisplays warnings when parsing the magic file or applying its tests.
106ff772f70SnicmUsually used for debugging.
107c1d344f8Saaron.El
1083746a816Saaron.Sh FILES
1093746a816Saaron.Bl -tag -width /etc/magic -compact
1103746a816Saaron.It Pa /etc/magic
111ff772f70Snicmdefault magic file
1123746a816Saaron.El
113f1c64ac4Sjmc.Sh EXIT STATUS
114f1c64ac4Sjmc.Ex -std file
115c1d344f8Saaron.Sh SEE ALSO
116c1d344f8Saaron.Xr magic 5
117ff772f70Snicm.Sh AUTHORS
118442f81f7Sjmc.An -nosplit
119ad0cc88dSajacoutot.Nm
120ff772f70Snicmcommands have appeared in many previous versions of
121ff772f70Snicm.Ux .
122442f81f7SjmcThis version was written by
123442f81f7Sjmc.An Nicholas Marriott
124442f81f7Sjmcfor
125ff772f70Snicm.Ox 5.8
126442f81f7Sjmcto replace the previous version originally written by
127442f81f7Sjmc.An Ian Darwin .
128c1d344f8Saaron.Pp
129ff772f70SnicmThere is a large number of contributors to the magic files; many are listed in
130ff772f70Snicmthe source files.
131