MarketFile (command)
Company Profile

File (command)

file is a shell command for reporting the type of data contained in a file. It is commonly supported in Unix and Unix-like operating systems.

History
The file command originated in Unix Research Version 4 in 1973. System V brought 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. Most major BSD and Linux distributions include a free, open-source implementation that was written from scratch by Ian Darwin in 1986–87. It keeps file type information in a text file with a format based on that of the System V version. 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. The OpenBSD system has its own subset implementation written from scratch, but still uses the Darwin/Zoulas collection of magic file formatted information. The command was ported to the IBM i operating system. As of version 4.00 of the Ian Darwin/Christos Zoulas implementation of file, the functionality of the command is implemented in and exposed by a libmagic library that is accessible to consuming code via C (and compatible) linking. ==Usage==
Usage
The SUS mandates the following command-line options: • -M file, prevents the default position-sensitive and context-sensitive tests in favor of the tests specified in a specially formatted file • -m file, same as for -M, but with tests in addition to the default • -d, selects default position-sensitive and context-sensitive tests; this is the default behavior unless -M or -m are specified • -h, do not dereference symbolic links that point to an existing file or directory • -L, dereference the symbolic link that points to an existing file or directory • -i, do not classify the file further than to report as: nonexistent, a block special file, a character special file, a directory, a FIFO, a socket, a symbolic link, or a regular file; the Ian Darwin and OpenBSD versions behave differently with this option and instead output an Internet media type ("MIME type") identifying the recognized file format Implementations may add extra options. Ian Darwin's implementation adds -s 'special files', -k 'keep-going' or -r 'raw', among many others. ==Examples==
Examples
For a C source code file, reports: main.c: C program text For a compiled executable, reports information like: program: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped For a block device /dev/hda, reports: /dev/hda1: block special (0/0) By default, file does not try to read a device file due to potential undesirable effects. But using the non-standard option (available in the Ian Darwin branch), which requests to read device files to identify content, reports details such as: /dev/hda1: Linux/i386 ext2 filesystem Via Ian Darwin's non-standard option -k, the command does not stop after the first hit found, but looks for other matching patterns. The -r option, which is available in some versions, causes the new line character to be displayed in its raw form rather than in its octal representation. On Linux, reports information like: libmagic-dev_5.35-4_armhf.deb: Debian binary package (format 2.0) - current ar archive - data For a compressed file, reports information like: compressed.gz: gzip compressed data, deflated, original filename, `compressed', last modified: Thu Jan 26 14:08:23 2006, os: Unix For a compressed file, reports information like: compressed.gz: application/x-gzip; charset=binary For a PPM file, reports: data.ppm: Netpbm PPM "rawbits" image data For a Mach-O universal binary, reports like: /bin/cat: Mach-O universal binary with 2 architectures /bin/cat (for architecture ppc7400): Mach-O executable ppc /bin/cat (for architecture i386): Mach-O executable i386 For a symbolic link, reports: /usr/bin/vi: symbolic link to vim Identifying a symbolic link is not available on all platforms and will be dereferenced if -L is passed or POSIXLY_CORRECT is set. == See also ==
tickerdossier.comtickerdossier.substack.com