Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
File (command)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Shell command for reporting file type information}} {{Redirects here|File (software)|the file management program bundled with [[iOS 11]]|Files (software)}} {{lowercase title}} {{Infobox software | name = file | logo = <!-- [[File: ]] --> | logo caption = | screenshot = File-example-command-gimp.gif | caption = Example usage of {{code|file}} | collapsible = | author = | developer = [[AT&T Bell Laboratories]] | released = {{Start date|1973|df=yes}} as part of [[Unix Research Version 4]]; {{Start date|1986|df=yes}} open-source reimplementation | discontinued = | latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}} | latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}} | latest preview version = | latest preview date = <!-- {{Start date and age|YYYY|MM|DD|df=yes/no}} --> | repo = {{URL|https://github.com/file/file}} | programming language = [[C (programming language)|C]] | operating system = [[Unix]], [[Unix-like]], [[Plan 9 from Bell Labs|Plan 9]], [[IBM i]] | platform = [[Cross-platform]] | size = | language = | genre = [[File type]] detector | license = [[BSD license]], [[Common Development and Distribution License|CDDL]]<br />Plan 9: [[MIT License]] | alexa = | website = {{URL|https://darwinsys.com/file/}} }} '''<code>file</code>''' is a [[Shell (computing)|shell]] [[command (computing)|command]] for reporting the type of data contained in a [[computer file|file]]. It is commonly supported in [[Unix]] and [[Unix-like]] [[operating systems]]. As the command uses relatively quick-running [[heuristic]]s to determine [[file type]], it can report misleading information. The command can be fooled, for example, by including a magic number in the content even if the rest of the content does not match what the magic number indicates. The command report cannot be taken as completely trustworthy. The [[Single UNIX Specification]] (SUS) requires the command to exhibit the following behavior with respect to the file specified via the [[command-line interface|command-line]]: # If the file cannot be read, or its [[Unix file type]] is undetermined, the command will report that the file was processed but its type was undetermined # The command must be able to determine the types [[folder (computing)|directory]], [[named pipe|FIFO]], [[Unix domain socket|socket]], block [[device file|special file]], and character special file # A zero-length file is reported as such # An initial part of file is considered and the command is to use position-sensitive tests # The entire file is considered and the command is to use context-sensitive tests # Otherwise, the file is reported as a data file Position-sensitive tests are normally implemented by matching various locations within the file against a textual database of [[Magic number (programming)|magic number]]s (see the Usage section). This differs from other simpler methods such as [[file extension]]s and schemes like [[MIME]]. In the System V implementation, the Ian Darwin implementation, and the OpenBSD implementation, the command uses a database to drive the probing of the lead bytes. That database is stored as a file that is located in <code>/etc/magic</code>, <code>/usr/share/file/magic</code> or similar.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)