1.\" $OpenBSD: file.1,v 1.44 2015/12/24 11:45:34 jca Exp $ 2.\" $FreeBSD: src/usr.bin/file/file.1,v 1.16 2000/03/01 12:19:39 sheldonh Exp $ 3.\" 4.\" Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org> 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. 8.\" 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. 18.\" 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. 30.\" 31.Dd $Mdocdate: December 24 2015 $ 32.Dt FILE 1 33.Os 34.Sh NAME 35.Nm file 36.Nd determine file type 37.Sh SYNOPSIS 38.Nm 39.Op Fl bchiLsW 40.Ar 41.Sh DESCRIPTION 42The 43.Nm 44utility tests each argument and attempts to determine its type. 45Three sets of tests are performed: 46.Bl -enum -offset Ds 47.It 48Filesystem tests, for example if a file is empty, or a special file such as a 49socket or named pipe (FIFO). 50.It 51.Dq Magic 52tests for data in particular fixed formats. 53These are loaded from the 54.Pa /etc/magic 55file (or 56.Pa ~/.magic 57instead if it exists and 58.Nm 59is not running as root). 60The file format is described in 61.Xr magic 5 . 62.It 63Tests for text files such as plain ASCII or C programming language files. 64.El 65.Pp 66The first test which succeeds causes the file type to be printed. 67The type will often contain one of the words 68.Em text 69(contains only printing characters and is probably safe to read on an ASCII 70terminal), 71.Em executable 72(the file contains a compiled executable program) 73or 74.Em data 75meaning anything else. 76.Pp 77If 78.Ar file 79is a single dash 80.Pq Sq - , 81.Nm 82reads from the standard input. 83.Pp 84The options are as follows: 85.Bl -tag -width indent 86.It Fl b , -brief 87Does not prepend filenames to output lines. 88.It Fl c 89Prints a summary of the parsed magic file; usually used for debugging. 90.It Fl h 91Causes symlinks not to be followed. 92This is the default. 93.It Fl i , -mime , -mime-type 94Outputs MIME type strings rather than the more 95traditional human-readable ones. 96Thus it may say 97.Dq text/plain 98rather than 99.Dq ASCII text . 100.It Fl L , -dereference 101Causes symlinks to be followed. 102.It Fl s 103Attempts to read block and character device files, not just regular files. 104.It Fl W 105Displays warnings when parsing the magic file or applying its tests. 106Usually used for debugging. 107.El 108.Sh FILES 109.Bl -tag -width /etc/magic -compact 110.It Pa /etc/magic 111default magic file 112.El 113.Sh EXIT STATUS 114.Ex -std file 115.Sh SEE ALSO 116.Xr magic 5 117.Sh AUTHORS 118.An -nosplit 119.Nm 120commands have appeared in many previous versions of 121.Ux . 122This version was written by 123.An Nicholas Marriott 124for 125.Ox 5.8 126to replace the previous version originally written by 127.An Ian Darwin . 128.Pp 129There is a large number of contributors to the magic files; many are listed in 130the source files. 131