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 mode: don’t print filenames.
-
-c Check the format of the magic file (
filesargument is invalid with-c). Usually used with-m.-
-Fseparator Print
separatorbetween file and type, instead of a colon.-
-ffile Read the names of files to be checked from
file.-
-i Print the MIME type of the file instead of a human-readable description.
-
-k Don’t stop after the first match.
-
-L Follow symbolic links. By default, symbolic links are not followed.
-
-mfile Search for file types in
fileinstead of/etc/magic.-
-N Don’t pad filenames for alignment.
-
-v Print the version.
-
-z 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"Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access