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 .sp 17 .LP 18 \fBfile\fR performs a series of tests on each \fIfilename\fR in an attempt to 19 determine what it contains. If the contents of a file appear to be \fBASCII\fR 20 text, \fBfile\fR examines the first 512 bytes and tries to guess its language. 21 .sp 22 .LP 23 \fBfile\fR uses the file \fB/etc/magic\fR to identify files that have some sort 24 of \fImagic number\fR, that is, any file containing a numeric or string 25 constant that indicates its type. 26 .SH OPTIONS 27 .sp 28 .ne 2 29 .na 30 \fB\fB-c\fR\fR 31 .ad 32 .RS 12n 33 Check for format errors in the magic number file. For reasons of efficiency, 34 this validation is not normally carried out. No file type-checking is done 35 under \fB-c\fR. 36 .RE 37 38 .sp 39 .ne 2 40 .na 41 \fB\fB-f\fR \fIffile\fR\fR 42 .ad 43 .RS 12n 44 Get a list of filenames to identify from \fIffile.\fR 45 .RE 46 47 .sp 48 .ne 2 49 .na 50 \fB\fB-L\fR\fR 51 .ad 52 .RS 12n 53 If a file is a symbolic link, test the file the link references rather than the 54 link itself. 55 .RE 56 57 .sp 58 .ne 2 59 .na 60 \fB\fB-m\fR\fI mfile\fR\fR 61 .ad 62 .RS 12n 63 Use \fImfile\fR as the name of an alternate magic number file. 64 .RE 65 66 .SH EXAMPLES 67 .LP 68 \fBExample 1 \fRUsing \fBfile\fR on all the files in a specific user's 69 directory. 70 .sp 71 .LP 72 This example illustrates the use of \fBfile\fR on all the files in a specific 73 user's directory: 74 75 .sp 76 .in +2 77 .nf 78 example% \fBpwd 79 /usr/blort/misc\fR 80 .fi 81 .in -2 82 .sp 83 84 .sp 85 .in +2 86 .nf 87 example% \fB/usr/ucb/file *\fR 88 89 code: mc68020 demand paged executable 90 code.c: c program text 91 counts: ascii text 92 doc: roff,nroff, or eqn input text 93 empty.file: empty 94 libz: archive random library 95 memos: directory 96 project: symboliclink to /usr/project 97 script: executable shell script 98 titles: ascii text 99 s5.stuff: cpio archive 100 101 102 example% 103 .fi 104 .in -2 105 .sp 106 107 .SH ENVIRONMENT VARIABLES 108 .sp 109 .LP 110 The environment variables \fBLC_CTYPE\fR, \fBLANG\fR, and \fBLC_default\fR 111 control the character classification throughout \fBfile\fR. On entry to 112 \fBfile\fR, these environment variables are checked in the following order: 113 \fBLC_CTYPE\fR, \fBLANG\fR, and \fBLC_default\fR. When a valid value is found, 114 remaining environment variables for character classification are ignored. For 115 example, a new setting for \fBLANG\fR does not override the current valid 116 character classification rules of \fBLC_CTYPE\fR. When none of the values is 117 valid, the shell character classification defaults to the POSIX.1 "C" 118 locale. 119 .SH FILES 120 .sp 121 .LP 122 \fB/etc/magic\fR 123 .SH SEE ALSO 124 .sp 125 .LP 126 \fBmagic\fR(4), \fBattributes\fR(5) 127 .SH BUGS 128 .sp 129 .LP 130 \fBfile\fR often makes mistakes. In particular, it often suggests that command 131 files are C programs. 132 .sp 133 .LP 134 \fBfile\fR does not recognize Pascal or LISP.