summaryrefslogtreecommitdiff
path: root/usr.bin/file/file.1
blob: 8572afb1cf0ab94e3854ac05cdb66f6a54c8316e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
.\" $OpenBSD: file.1,v 1.43 2015/07/30 11:13:24 jmc Exp $
.\" $FreeBSD: src/usr.bin/file/file.1,v 1.16 2000/03/01 12:19:39 sheldonh Exp $
.\"
.\" Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
.\" Copyright (c) Ian F. Darwin 1986-1995.
.\" Software written by Ian F. Darwin and others;
.\" maintained 1995-present by Christos Zoulas and others.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice immediately at the beginning of the file, without modification,
.\"    this list of conditions, and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd $Mdocdate: July 30 2015 $
.Dt FILE 1
.Os
.Sh NAME
.Nm file
.Nd determine file type
.Sh SYNOPSIS
.Nm
.Op Fl bchiLsW
.Ar
.Sh DESCRIPTION
The
.Nm
utility tests each argument and attempts to determine its type.
Three sets of tests are performed:
.Bl -enum -offset Ds
.It
Filesystem tests, for example if a file is empty, or a special file such as a
socket or named pipe (FIFO).
.It
.Dq Magic
tests for data in particular fixed formats.
These are loaded from the
.Pa /etc/magic
file (or
.Pa ~/.magic
instead if it exists and
.Nm
is not running as root).
The file format is described in
.Xr magic 5 .
.It
Tests for text files such as plain ASCII or C programming language files.
.El
.Pp
The first test which succeeds causes the file type to be printed.
The type will often contain one of the words
.Em text
(contains only printing characters and is probably safe to read on an ASCII
terminal),
.Em executable
(the file contains a compiled executable program)
or
.Em data
meaning anything else.
.Pp
If
.Ar file
is a single dash
.Pq Sq - ,
.Nm
reads from the standard input.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl b
Does not prepend filenames to output lines.
.It Fl c
Prints a summary of the parsed magic file; usually used for debugging.
.It Fl h
Causes symlinks not to be followed.
This is the default.
.It Fl i , -mime , -mime-type
Outputs MIME type strings rather than the more
traditional human-readable ones.
Thus it may say
.Dq text/plain
rather than
.Dq ASCII text .
.It Fl L
Causes symlinks to be followed.
.It Fl s
Attempts to read block and character device files, not just regular files.
.It Fl W
Displays warnings when parsing the magic file or applying its tests.
Usually used for debugging.
.El
.Sh FILES
.Bl -tag -width /etc/magic -compact
.It Pa /etc/magic
default magic file
.El
.Sh EXIT STATUS
.Ex -std file
.Sh SEE ALSO
.Xr magic 5
.Sh AUTHORS
.An -nosplit
.Nm
commands have appeared in many previous versions of
.Ux .
This version was written by
.An Nicholas Marriott
for
.Ox 5.8
to replace the previous version originally written by
.An Ian Darwin .
.Pp
There is a large number of contributors to the magic files; many are listed in
the source files.