file.1 revision 1.44
$OpenBSD: file.1,v 1.44 2015/12/24 11:45:34 jca 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: l -enum -offset Ds t Filesystem tests, for example if a file is empty, or a special file such as a socket or named pipe (FIFO). t .Dq Magic tests for data in particular fixed formats. These are loaded from the

a /etc/magic file (or

a ~/.magic instead if it exists and .Nm is not running as root). The file format is described in .Xr magic 5 . t Tests for text files such as plain ASCII or C programming language files. .El

p 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.

p If .Ar file is a single dash

q Sq - , .Nm reads from the standard input.

p The options are as follows: l -tag -width indent t Fl b , -brief Does not prepend filenames to output lines. t Fl c Prints a summary of the parsed magic file; usually used for debugging. t Fl h Causes symlinks not to be followed. This is the default. t 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 . t Fl L , -dereference Causes symlinks to be followed. t Fl s Attempts to read block and character device files, not just regular files. t Fl W Displays warnings when parsing the magic file or applying its tests. Usually used for debugging. .El .Sh FILES l -tag -width /etc/magic -compact t 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 x . This version was written by .An Nicholas Marriott for .Ox 5.8 to replace the previous version originally written by .An Ian Darwin .

p There is a large number of contributors to the magic files; many are listed in the source files.