Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

magic(4)

file(1)  —  Commands

OSF

NAME

file − Determines file type

SYNOPSIS

file [-c] [-f file_list] [-m magic_file] file ... 

The file command reads input files, performs a series of tests on each one, and attempts to classify them by type.  file then writes the file types to standard output. 

FLAGS

-cChecks the magic file (/etc/magic by default) for format errors.  This validation is not normally done.  File typing is not done under this flag. 

-ffile_list
Reads file_list for a list of files to examine. 

-mmagic_file
Specifies magic_file as the magic file (/etc/magic by default). 

DESCRIPTION

The file command uses the /etc/magic file to identify files that have some sort of a magic number (that is, any file containing a numeric or string constant that indicates its type). 

If a file appears to be plain text, file examines the first 512 bytes and tries to determine what kind of text it is.  If the first 512 bytes only contain ASCII characters, file returns either ASCII text or English text.  If the file contains other characters (that is, European or Asian extended characters), file returns data.  If a file does not appear to be plain text, file attempts to distinguish a binary data file from a text file that contains extended characters.  If the file is an a.out file and the version number is greater than zero, file displays the version stamp. 

EXAMPLES

     1.To display the type of information a file contains, enter:

file myfile

This displays the file type of myfile (directory, data, ASCII text, C program source, archive, and so on). 

     2.To display the type of each file named in a list of filenames, enter:

file -f filenames

This displays the type of each file with a name that appears in filenames.  Each filename must appear alone on a line.  To create filenames, enter:

ls > filenames

Then edit filenames as desired. 

FILES

/etc/magicFile type database. 

RELATED INFORMATION

magic(4)
 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026