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