file is a Unix shell (command-line) program for determining the type of data contained in a file. It does this by matching various locations within the file against a textual database of magic numbers. This differs from other simpler methods such as file extensions and MIME.
The original version of file originated in Unix Research Version 4 in 1973. System V saw a major update with several important changes, most notably moving the file type information into an external text file rather than compiling it into the binary itself. A free, open-source reimplementation was written by Ian Darwin from scratch. It was expanded by Geoff Collyer in 1989 and since then has had input from many others, including Guy Harris, Chris Lowth and Eric Fischer.
A few examples of file's output are:
# file file.c file.c: C program text # file program program: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped # file /dev/wd0a /dev/wd0a: block special (0/0) # file -s /dev/hda1 /dev/hda1: Linux/i386 ext2 filesystem # file -s /dev/hda5 /dev/hda5: Linux/i386 swap file # file compressed.gz compressed.gz: gzip compressed data, deflated, original filename, `compressed', last modified: Thu Jan 26 14:08:23 2006, os: Unix # file data.ppm data.ppm: Netpbm PPM "rawbits" image data
This article is licensed under the GNU Free Documentation License.
It uses material from the
"File (Unix)".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world