.\" $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 .\" 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.