File (Unix)

File (Unix)

file is a standard Unix program for determining the type of data contained in a computer file.

History

The original version of "file" originated in Unix Research Version 4 [See [http://www.darwinsys.com/file/file-v4.1.txt] this copy of the UNIX V4 man page] 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.

All major BSD and Linux distributions use a free, open-source reimplementation which was written in 1986-87 by Ian Darwin [The history of this program is recorded in its private CVS repository; see [http://www.darwinsys.com/file/file.c.log.txt] the log of the main program] 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; from late 1993 onward its maintenance has been organized by Christos Zoulas.

Specification

The Single Unix Specification (SUS) specifies that a series of tests are performed on the file specified on the command line:
* if the file cannot be read, its status undetermined, or its type undetermined, file will indicate that the file was processed and its type was undetermined.
* file must be able to determine the types directory, FIFO, socket, block special, and character special
* zero files are identified as such
* an initial part of file is considered and file is to use position-sensitive tests
* the entire file is considered and file is to use context-sensitive tests
* the file is identified as a data file

file's position-sensitive tests are normally implemented by matching various locations within the file against a textual database of magic numbers (see the Usage section). This differs from other simpler methods such as file extensions and schemes like MIME.

In most implementations, the file command uses a database to drive the probing of the lead bytes. That database is implemented in a file called "magic", whose location is usually in /etc/magic, /usr/share/file/magic or a similar location.

Usage

The SUS mandates the following options:

: -M "file", specify a file specially formatted containing position-sensitive tests; default position-sensitive tests and context-sensitive tests will not be performed: -m "file", as for -M, but default tests will be performed after the tests contained in file.: -d, perform default position-sensitive and context-sensitive tests to the given file; this is the default behaviour unless -M or -m is specified: -h, identify links as such, unless the link points to a nonexistent file: -i, do not classify the file further than to identify it as either a: nonexistent, directory, FIFO, socket, block special, character special, socket, symbolic link, regular file, empty file, unreadable file, executable, ar archive, extended cpio format, extended tar format, shell script, C programming language source, FORTRAN programming language source, or a data file

Other Unix and Unix-like operating systems may add extra options than these.

Examples

# 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

References

External links

* [http://www.opengroup.org/onlinepubs/009695399/utilities/file.html file] – specification from the Single Unix Specification

Manual pages

*man|1|file|OpenBSD
*man|1|file|Linux

Other

* [http://darwinsys.com/file/ Fine Free File Command] – homepage for version of file used in major BSD and Linux distributions.
* [http://www.iconv.com/file.htm An online interface to the "file" program.]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • File (Unix) — Pour les articles homonymes, voir File. file est une commande UNIX qui permet de déterminer le type d un fichier. Pour chaque fichier valide passé en paramètre, file tente de déterminer le type de données qu il contient et affiche cette… …   Wikipédia en Français

  • File (Unix) — file команда Unix, предназначенная для определения типа файла. Содержание 1 Использование 2 Ключи 3 См. также 4 …   Википедия

  • file (Unix) — Pour les articles homonymes, voir File. file …   Wikipédia en Français

  • File — has several meanings:* Filing cabinet * File (tool) * A nail file * Filing (legal) * Filing (manufacturing process) * File (formation) Military term for a single column of men one in front of the other. See also Rank (formation) * File (chess) *… …   Wikipedia

  • File (desambiguación) — Saltar a navegación, búsqueda File puede referirse a... File (Informática), nombre en inglés para archivo o fichero . File (Unix), un programa para análisis de archivos. File (Egipto), una antigua isla del Nilo. Obtenido de File… …   Wikipedia Español

  • Unix — (officially trademarked as UNIX, sometimes also written as Unix with small caps) is a computer operating system originally developed in 1969 by a group of AT T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and… …   Wikipedia

  • Unix security — Unix security: maintaining a secure environment on Unix and Unix like operating systems is dependent on design concepts of these operating systems, but vigilance through user and administrative techniques is important to maintain security… …   Wikipedia

  • File — Aktuelle Version: 5.01 (30. April 2009) Betriebssystem: Multiplattform Kategorie: Remote Access Lizenz: GPL …   Deutsch Wikipedia

  • file — Aktuelle Version 5.09 (16. September 2011) Betriebssystem Multiplattform Kategorie Remote Access Lizenz BSD Lizenz Deutschsprachig nein …   Deutsch Wikipedia

  • UNIX System V — Unix System V, commonly abbreviated SysV (and usually pronounced, though rarely written as System 5), was one of the versions of the Unix operating system. It was originally developed by AT T and first released in 1983. Four major versions of… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”