1 '\" te 2 .\" Copyright (c) 1992, Sun Microsystems, Inc. 3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. 4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. 5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] 6 .TH FILE 1B "Sep 14, 1992" 7 .SH NAME 8 file \- determine the type of a file by examining its contents 9 .SH SYNOPSIS 10 .LP 11 .nf 12 \fB/usr/ucb/file\fR [\fB-f\fR \fIffile\fR] [\fB-cL\fR] [\fB-m\fR \fImfile\fR] \fIfilename\fR... 13 .fi 14 15 .SH DESCRIPTION 16 .LP 17 \fBfile\fR performs a series of tests on each \fIfilename\fR in an attempt to 18 determine what it contains. If the contents of a file appear to be \fBASCII\fR 19 text, \fBfile\fR examines the first 512 bytes and tries to guess its language. 20 .sp 21 .LP 22 \fBfile\fR uses the file \fB/etc/magic\fR to identify files that have some sort 23 of \fImagic number\fR, that is, any file containing a numeric or string 24 constant that indicates its type. 25 .SH OPTIONS 26 .ne 2 27 .na 28 \fB\fB-c\fR\fR 29 .ad 30 .RS 12n 31 Check for format errors in the magic number file. For reasons of efficiency, 32 this validation is not normally carried out. No file type-checking is done 33 under \fB-c\fR. 34 .RE 35 36 .sp 37 .ne 2 38 .na 39 \fB\fB-f\fR \fIffile\fR\fR 40 .ad 41 .RS 12n 42 Get a list of filenames to identify from \fIffile.\fR 43 .RE 44 45 .sp 46 .ne 2 47 .na 48 \fB\fB-L\fR\fR 49 .ad 50 .RS 12n 51 If a file is a symbolic link, test the file the link references rather than the 52 link itself. 53 .RE 54 55 .sp 56 .ne 2 57 .na 58 \fB\fB-m\fR\fI mfile\fR\fR 59 .ad 60 .RS 12n 61 Use \fImfile\fR as the name of an alternate magic number file. 62 .RE 63 64 .SH EXAMPLES 65 .LP 66 \fBExample 1 \fRUsing \fBfile\fR on all the files in a specific user's 67 directory. 68 .sp 69 .LP 70 This example illustrates the use of \fBfile\fR on all the files in a specific 71 user's directory: 72 73 .sp 74 .in +2 75 .nf 76 example% \fBpwd 77 /usr/blort/misc\fR 78 .fi 79 .in -2 80 .sp 81 82 .sp 83 .in +2 84 .nf 85 example% \fB/usr/ucb/file *\fR 86 87 code: mc68020 demand paged executable 88 code.c: c program text 89 counts: ascii text 90 doc: roff,nroff, or eqn input text 91 empty.file: empty 92 libz: archive random library 93 memos: directory 94 project: symbolic link to /usr/project 95 script: executable shell script 96 titles: ascii text 97 s5.stuff: cpio archive 98 99 100 example% 101 .fi 102 .in -2 103 .sp 104 105 .SH ENVIRONMENT VARIABLES 106 .LP 107 The environment variables \fBLC_CTYPE\fR, \fBLANG\fR, and \fBLC_default\fR 108 control the character classification throughout \fBfile\fR. On entry to 109 \fBfile\fR, these environment variables are checked in the following order: 110 \fBLC_CTYPE\fR, \fBLANG\fR, and \fBLC_default\fR. When a valid value is found, 111 remaining environment variables for character classification are ignored. For 112 example, a new setting for \fBLANG\fR does not override the current valid 113 character classification rules of \fBLC_CTYPE\fR. When none of the values is 114 valid, the shell character classification defaults to the POSIX.1 "C" 115 locale. 116 .SH FILES 117 .LP 118 \fB/etc/magic\fR 119 .SH SEE ALSO 120 .LP 121 \fBmagic\fR(4), \fBattributes\fR(5) 122 .SH BUGS 123 .LP 124 \fBfile\fR often makes mistakes. In particular, it often suggests that command 125 files are C programs. 126 .sp 127 .LP 128 \fBfile\fR does not recognize Pascal or LISP.