file Command Purpose Determines the file type. Syntax To Classify the File Type file [ -m MagicFile ] [ -f FileList ] [ File ... ] To Check the Magic File for Format Errors file -c [ -m MagicFile ] Description The file command reads the files specified by the File or -f FileList parameter, performs a series of tests on each one, and attempts to classify them by types. The command then writes the file types to standard output. If a file appears to be ASCII, the file command examines the first 512 bytes and determines its language. If a file does not appear to be ASCII, the file command further attempts to distin- guish a binary data file from a text file that contains extended characters. If the File parameter specifies an executable or object module file and the version number is greater than 0, the file command displays the version stamp. The ld command explains the use of a.out files. 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 type. The file command uses the magic.cat message catalog. If magic.cat message catalog cannot be opened, the file command uses the /etc/magic file. Flags -c Checks the specified MagicFile (the /etc/magic file, by de- fault) for format errors. This validation is not normally done. File typing is not done under this flag. -f FileList Reads the FileList parameter for a list of files to examine. -m MagicFile Specifies the magic file (the /etc/magic file, by default) as the value of the magic file variable. Exit Status This command returns the following exit values: 0 Successful completion. >0 An error occurred. Examples 1. To display the type of information a file contains, enter: file myfile This displays the file type of myfile (such as directory, data, ASCII text, C-program source, and archive). 2. To display the type of each file named in a list of file names, enter: file -f filenames This displays the type of each file named in the filenames list. Each file name must appear alone on a line. To create filenames, enter: ls >filenames Then edit the filenames list as desired. Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Files /usr/bin/file Contains the file command. /etc/magic Contains the file type database. Related Information File Systems, Directories, and Files Overview in AIX Version 3.2 System User's Guide: Base and Devices. Input and Output Redirection Overview in AIX Version 3.2 System User's Guide: Base and Devices describes how the operating system processes input and output. Files Overview in AIX Version 3.2 System User's Guide: Base and Devices describes files, file types, and how to name files. Understanding File and Directory Access Modes in AIX Version 3.2 System User's Guide: Base and Devices introduces file ownership and permissions to access files and directories. The find command, ld command.