O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

file

Synopsis

file [options] files

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

Options

-b, --brief

Brief mode: don't print filenames.

-c, --checking-printout

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

-F separator, --separator separator

Print separator between file and type, instead of a colon.

-f file, --files-from file

Read the names of files to be checked from file.

-i, --mime

Print the MIME type of the file instead of a human-readable description.

-k, --keep-going

Don't stop after the first match.

-L, --dereference

Follow symbolic links. By default, symbolic links are not followed.

-m file, --magic-file file

Search for file types in file instead of /etc/magic.

-N, --no-pad

Don't pad filenames for alignment.

-v, --version

Print the version.

-z, --uncompress

Attempt checking of compressed files.

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

Apple QuickTime movie file (moov)
ASCII text
data
directory
gzip compressed data
empty
PDF document, version 1.4
Mach-O executable ppc
sticky symbolic link to private/tmp

Example

List all PDF Version 1.1 files:

$ file * | grep "PDF document, version 1.1"

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required