Name

file

Synopsis

    file [options]files

Classify the named files according to the type of data they contain. file checks the magic file (usually /etc/magic) to identify many common file types.

Many file types are understood. Output lists each filename, followed by a brief classification such as:

    ascii text
    c program text
    c shell commands
    data
    empty
    iAPX 386 executable
    directory
    [nt]roff, tbl, or eqn input text
    shell commands
    symbolic link to ../usr/etc/arp

Mac OS X and GNU/Linux use the freely-available version of file from ftp://ftp.astron.com/pub/file/.

Solaris Options

-c

Check the format of the magic file (files argument is invalid with -c).

-d

Apply any default system tests that are position-dependent or context-dependent to the file.

-f listfile

Run file on the filenames in listfile.

-h

Do not follow symbolic links.

-i

For regular files, do not attempt to classify the file further. Instead, just print the message “regular file.”

-m file

/usr/xpg4/bin/magic: same as -M.

/usr/bin/magic: use file as the magic file instead of /etc/magic.

-M file

file contains position-dependent or context-sensitive tests to apply.

Astron.com file Options

-b, --brief

Brief mode; do not prepend filenames to output lines.

-c, --checking-printout

Check the format of the magic file (files argument is invalid with -c). Usually used with -m.

-C, --compile

Create a magic.mgc file, which is a preparsed version of the magic file.

-ffile, --files-fromfile

Read the names of files to be checked from file.

-Fsep, --separator ...

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.